blob: 0cc48b1181fdfa129d353a3836483fa10c821d42 (
plain)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#pragma once
#define deimos_StaticAssert(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
#define deimos_NO_COPY(TYPE) \
TYPE(const TYPE&) = delete; \
TYPE& operator=(const TYPE&) = delete;
#define deimos_NO_MOVE(TYPE) \
TYPE(TYPE&&) = delete; \
TYPE& operator=(TYPE&&) = delete;
#define deimos_NO_COPY_MOVE(TYPE) \
deimos_NO_COPY(TYPE); \
deimos_NO_MOVE(TYPE);
#define deimos_DEFAULT_COPY(TYPE) \
TYPE(const TYPE&) = default; \
TYPE& operator=(const TYPE&) = default;
#define deimos_DEFAULT_MOVE(TYPE) \
TYPE(TYPE&&) = default; \
TYPE& operator=(TYPE&&) = default;
#define deimos_DEFAULT_COPY_MOVE(TYPE) \
deimos_DEFAULT_COPY(TYPE); \
deimos_DEFAULT_MOVE(TYPE);
namespace gsl
{
using zstring = char*;
using czstring = const char*;
} // namespace gsl
namespace deimos
{
using uint8 = unsigned char;
using uint16 = unsigned short;
using uint32 = unsigned int;
using uint64 = unsigned long long;
using int8 = char;
using int16 = short;
using int32 = int;
using int64 = long long;
using float32 = float;
using float64 = double;
enum __attribute__((__may_alias__)) byte : uint8 {};
struct uint128
{
uint64 high;
uint64 low;
constexpr bool operator==(const uint128& other) const = default;
};
struct SourceLocation
{
gsl::czstring file;
int32 line;
constexpr SourceLocation( // NOLINT
gsl::czstring file_ = __builtin_FILE(),
int32 line_ = __builtin_LINE()) :
file{file_},
line{line_}
{}
};
template<typename T> struct RemoveReferenceT { using Type = T; };
template<typename T> struct RemoveReferenceT<T&> { using Type = T; };
template<typename T> struct RemoveReferenceT<T&&> { using Type = T; };
template<typename T> using RemoveReference = RemoveReferenceT<T>::Type;
template<typename T> constexpr bool kIsTriviallyDestructible = __is_trivially_destructible(T);
} // namespace deimos
constexpr void* operator new(deimos::uint64, void* ptr)
{
return ptr;
}
namespace std
{
template<typename T>
constexpr deimos::RemoveReference<T>&& move(T&& t) noexcept
{
return static_cast<deimos::RemoveReference<T>&&>(t);
}
template<typename T>
constexpr T&& forward(deimos::RemoveReference<T>& t) noexcept
{
return static_cast<T&&>(t);
}
template<typename T>
constexpr T&& forward(deimos::RemoveReference<T>&& t) noexcept // NOLINT
{
return static_cast<T&&>(t);
}
template<typename T, typename U = T>
constexpr T exchange(T& obj, U&& new_value)
{
T old_value = std::move(obj);
obj = std::forward<U>(new_value);
return old_value;
}
} // namespace std
|