23 #include <type_traits>
31 template <
typename TDestination,
class TSource>
35 static_assert(
sizeof(TDestination) ==
sizeof(TSource),
36 "The destination type should have the same size as the source type.");
37 static_assert(std::is_trivially_copyable_v<TDestination>,
"The destination type should be trivially copyable");
38 static_assert(std::is_trivially_copyable_v<TSource>,
"The source type should be trivially copyable.");
41 std::remove_const_t<TDestination> result;
42 std::memcpy(&result, &source,
sizeof(TSource));
49 #endif // itkBitCast_h