-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
86 lines (78 loc) · 2.61 KB
/
Copy pathmain.cpp
File metadata and controls
86 lines (78 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//#define _CRT_SECURE_NO_WARNINGS
//#define NOMINMAX
// namespace gstd {
//
// auto VirtualMemorySource::AllocateRegion(std::uint64_t size) -> Span<Byte> {
// static_assert(sizeof(std::uint64_t) == sizeof(SIZE_T), "!!!");
//
// SYSTEM_INFO systemInfo;
// GetSystemInfo(&systemInfo);
//
// std::uint64_t alignedSize = 0;
//
// if (size > std::numeric_limits<std::uint64_t>::max() - systemInfo.dwAllocationGranularity) {
// Panic("!!!");
// }
//
// if (size % systemInfo.dwAllocationGranularity == 0) {
// alignedSize = size;
// } else {
// alignedSize = size - (size % systemInfo.dwAllocationGranularity) + systemInfo.dwAllocationGranularity;
// }
//
// LPVOID memory = VirtualAlloc(nullptr,
// alignedSize,
// MEM_COMMIT | MEM_RESERVE,
// PAGE_READWRITE);
//
// if (!memory) {
// Panic("!!!");
// }
//
// return MakeSpan(StaticCast<Span<Byte>::Pointer>(memory),
// alignedSize);
// }
//
// auto VirtualMemorySource::DeallocateRegion(const Span<Byte> ®ion) -> void {
// // TODO: check
//
// VirtualFree(StaticCast<LPVOID>(region.begin()),
// 0,
// MEM_RELEASE);
// }
//
// }
// Container - is an interface on memory with algorithms.
// --------- ------ ----------
/*
* |--------|
* | Memory |
* |--------|
*
* Region -> Memory
* AllocationStrategy -> Algorithm
* Allocator -> Container
*
* Allocator = (Container + Algorithm) | Container ? => (Container + Algorithm)
*
* MemoryManager - abstraction on memory, that can control all memory in region all time?
*
*/
#include <gstd/gstd.h>
int main() {
// gstd::StackMemorySource<2 * gstd::Kb> memorySource;
// gstd::LinearAllocator allocator(&memorySource);
// gstd::Vector<int> v(&allocator);
// gstd::Set<int> s(&allocator);
// v.Append({1, 2, 3, 4});
// v | gstd::Sort() | gstd::Into<gstd::Vector<int>>();
// v.Sort(gstd::QuickSortAlgorithm);
gstd::TSliceFromT<1, int &, int &> t;
static_assert(std::is_same_v<decltype(t), gstd::TArray<int &>>);
static_assert(std::is_same_v<gstd::TConvertT<gstd::TSliceFromT<1, int &, int &, int &>, gstd::Tuple<>>, gstd::Tuple<int &, int &>>);
gstd::Tuple<int, float, char> u(1, 1.0, '1');
auto &i = u.Value();
auto r = u.get<2>();
// static_assert(std::is_same_v<gstd::LikeT<const int *, float>, const float>)
return 0;
}