11 #include <type_traits>
17 #if defined(_MSC_VER) && _MSC_VER >= 1928
18 #define __SYCL_HAS_BUILTIN_BIT_CAST 1
19 #elif defined(__has_builtin)
20 #define __SYCL_HAS_BUILTIN_BIT_CAST __has_builtin(__builtin_bit_cast)
22 #define __SYCL_HAS_BUILTIN_BIT_CAST 0
25 #if __cplusplus >= 202002L
29 #if __cpp_lib_bit_cast
32 #define __SYCL_BITCAST_IS_CONSTEXPR 1
33 #elif __SYCL_HAS_BUILTIN_BIT_CAST
35 #define __SYCL_BITCAST_IS_CONSTEXPR 1
42 inline namespace _V1 {
44 template <
typename To,
typename From>
45 #if defined(__SYCL_BITCAST_IS_CONSTEXPR)
48 std::enable_if_t<
sizeof(To) ==
sizeof(From) &&
49 std::is_trivially_copyable<From>::value &&
50 std::is_trivially_copyable<To>::value,
53 #if __cpp_lib_bit_cast
55 return std::bit_cast<To>(from);
56 #elif __SYCL_HAS_BUILTIN_BIT_CAST
58 return __builtin_bit_cast(To, from);
61 static_assert(std::is_trivially_default_constructible<To>::value,
62 "To must be trivially default constructible");
64 sycl::detail::memcpy(&to, &from,
sizeof(To));
std::enable_if_t< sizeof(To)==sizeof(From) &&std::is_trivially_copyable< From >::value &&std::is_trivially_copyable< To >::value, To > bit_cast(const From &from) noexcept
_Abi const simd< _Tp, _Abi > & noexcept