[libc-commits] [libc] [libc] Make BigInt bit_cast-able to compatible types (PR #75063)
via libc-commits
libc-commits at lists.llvm.org
Mon Dec 18 09:58:02 PST 2023
================
@@ -952,6 +952,35 @@ struct make_signed<UInt<Bits>> : type_identity<Int<Bits>> {
"Number of bits in Int should be a multiple of 64.");
};
+namespace internal {
+template <typename T> struct is_custom_uint : cpp::false_type {};
+template <size_t Bits> struct is_custom_uint<UInt<Bits>> : cpp::true_type {};
+} // namespace internal
+
+// bit_cast to UInt
+template <typename To, typename From,
+ typename = cpp::enable_if_t<internal::is_custom_uint<To>::value>,
+ typename = cpp::enable_if_t<sizeof(To) == sizeof(From)>,
+ typename = cpp::enable_if_t<cpp::is_trivially_copyable<From>::value>>
----------------
lntue wrote:
Why using separate template parameters for the conditions instead of logically combining in just one `enable_if_t`?
https://github.com/llvm/llvm-project/pull/75063
More information about the libc-commits
mailing list