22 #if __cplusplus < 202002L
25 # include <type_traits>
32 template <
typename TDestination,
class TSource>
36 static_assert(
sizeof(TDestination) ==
sizeof(TSource),
37 "The destination type should have the same size as the source type.");
38 static_assert(std::is_trivially_copyable<TDestination>::value,
"The destination type should be trivially copyable");
39 static_assert(std::is_trivially_copyable<TSource>::value,
"The source type should be trivially copyable.");
42 std::remove_const_t<TDestination> result;
43 std::memcpy(&result, &source,
sizeof(TSource));
61 #endif // itkBitCast_h