From 00c0d78199fcfbbb20828be5e06fd2d271fa4c1e Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Sun, 24 Mar 2024 23:49:26 +0100 Subject: Initial commit --- deimos/core/base.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 deimos/core/base.h (limited to 'deimos/core/base.h') diff --git a/deimos/core/base.h b/deimos/core/base.h new file mode 100644 index 0000000..0530db7 --- /dev/null +++ b/deimos/core/base.h @@ -0,0 +1,87 @@ +#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 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; + +struct uint128 +{ + uint64 high; + uint64 low; +}; + +template struct RemoveReferenceT { using Type = T; }; +template struct RemoveReferenceT { using Type = T; }; +template struct RemoveReferenceT { using Type = T; }; +template using RemoveReference = RemoveReferenceT::Type; + +template constexpr bool kIsTriviallyDestructible = __is_trivially_destructible(T); + +} // namespace deimos + +constexpr void* operator new(deimos::uint64, void* ptr) +{ + return ptr; +} + +namespace std +{ + +template +constexpr deimos::RemoveReference&& move(T&& t) noexcept +{ + return static_cast&&>(t); +} + +template +constexpr T&& forward(deimos::RemoveReference& t) noexcept +{ + return static_cast(t); +} + +template +constexpr T&& forward(deimos::RemoveReference&& t) noexcept // NOLINT +{ + return static_cast(t); +} + +} // namespace std + -- cgit