From dfbf09f4b936eaf6042fb0b2ab431eb986c330d2 Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 17 Jul 2023 20:32:07 +0200 Subject: GCC build fix --- src/common/Utilities/advstd.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/common') diff --git a/src/common/Utilities/advstd.h b/src/common/Utilities/advstd.h index 5b9991854bf..5bdfb52b533 100644 --- a/src/common/Utilities/advstd.h +++ b/src/common/Utilities/advstd.h @@ -18,6 +18,13 @@ #ifndef TRINITY_ADVSTD_H #define TRINITY_ADVSTD_H +#include + +#ifdef __cpp_lib_bit_cast +#include +#else +#include // for memcpy +#endif #include // this namespace holds implementations of upcoming stdlib features that our c++ version doesn't have yet @@ -26,6 +33,23 @@ namespace advstd // libc++ is missing these two [[nodiscard]] constexpr bool is_eq(std::partial_ordering cmp) noexcept { return cmp == 0; } [[nodiscard]] constexpr bool is_neq(std::partial_ordering cmp) noexcept { return cmp != 0; } + +#ifdef __cpp_lib_bit_cast +using std::bit_cast; +#else +// libstdc++ v10 is missing this +template , + std::is_trivially_copyable, + std::is_trivially_copyable>, int> = 0> +[[nodiscard]] constexpr To bit_cast(From const& from) noexcept +{ + To to; + std::memcpy(&to, &from, sizeof(To)); + return to; +} +#endif } #endif -- cgit v1.2.3