summaryrefslogtreecommitdiff
path: root/deimos/core/std.h
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-04-04 23:29:08 +0200
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-04-04 23:29:08 +0200
commit8970c40ce9a9a4e5f582b48f69b77bd90d8e678e (patch)
tree4f79981115baee14a25228755cdc81088ade2431 /deimos/core/std.h
parentf3ba19b162a89b2081c0598b4a0bf126146e3671 (diff)
Add DLL API
Diffstat (limited to 'deimos/core/std.h')
-rw-r--r--deimos/core/std.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/deimos/core/std.h b/deimos/core/std.h
index 89d7da5..42bedbe 100644
--- a/deimos/core/std.h
+++ b/deimos/core/std.h
@@ -22,6 +22,7 @@ template<typename T> concept signed_integral = integral<T> && __is_signed(T);
template<typename T> concept unsigned_integral = integral<T> && __is_unsigned(T);
template<typename T> constexpr bool is_trivially_destructible_v = __is_trivially_destructible(T);
+template<typename T> constexpr bool is_trivially_copyable_v = __is_trivially_copyable(T);
template<typename U, typename V> constexpr bool _is_same_helper = false;
template<typename T> constexpr bool _is_same_helper<T, T> = true;
@@ -78,6 +79,13 @@ constexpr T exchange(T& obj, U&& new_value)
enum __attribute__((__may_alias__)) byte : uint8_t {};
static_assert(sizeof(byte) == 1, "");
+template<typename To, typename From>
+requires (sizeof(To) == sizeof(From)) && is_trivially_copyable_v<To> && is_trivially_copyable_v<From>
+constexpr To bit_cast(const From& from) noexcept
+{
+ return __builtin_bit_cast(To, from);
+}
+
template<typename T>
class initializer_list
{