summaryrefslogtreecommitdiff
path: root/deimos/core/std.h
diff options
context:
space:
mode:
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
{