Index: base/bit_cast.h |
diff --git a/base/bit_cast.h b/base/bit_cast.h |
index c9514bceef4d861f660aa200eaccc997c6588361..90dd925e86cd9f0510a255a2f3a945637a46e5ea 100644 |
--- a/base/bit_cast.h |
+++ b/base/bit_cast.h |
@@ -9,6 +9,7 @@ |
#include <type_traits> |
#include "base/compiler_specific.h" |
+#include "base/template_util.h" |
#include "build/build_config.h" |
// bit_cast<Dest,Source> is a template function that implements the equivalent |
@@ -63,34 +64,10 @@ template <class Dest, class Source> |
inline Dest bit_cast(const Source& source) { |
static_assert(sizeof(Dest) == sizeof(Source), |
"bit_cast requires source and destination to be the same size"); |
- |
-#if (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) || \ |
- (defined(__clang__) && defined(_LIBCPP_VERSION))) |
- // GCC 5.1 contains the first libstdc++ with is_trivially_copyable. |
- // Assume libc++ Just Works: is_trivially_copyable added on May 13th 2011. |
- // However, with libc++ when GCC is the compiler the trait is buggy, see |
- // crbug.com/607158, so fall back to the less strict variant for non-clang. |
- static_assert(std::is_trivially_copyable<Dest>::value, |
- "non-trivially-copyable bit_cast is undefined"); |
- static_assert(std::is_trivially_copyable<Source>::value, |
- "non-trivially-copyable bit_cast is undefined"); |
-#elif HAS_FEATURE(is_trivially_copyable) |
- // The compiler supports an equivalent intrinsic. |
- static_assert(__is_trivially_copyable(Dest), |
- "non-trivially-copyable bit_cast is undefined"); |
- static_assert(__is_trivially_copyable(Source), |
- "non-trivially-copyable bit_cast is undefined"); |
-#elif COMPILER_GCC |
- // Fallback to compiler intrinsic on GCC and clang (which pretends to be |
- // GCC). This isn't quite the same as is_trivially_copyable but it'll do for |
- // our purpose. |
- static_assert(__has_trivial_copy(Dest), |
- "non-trivially-copyable bit_cast is undefined"); |
- static_assert(__has_trivial_copy(Source), |
- "non-trivially-copyable bit_cast is undefined"); |
-#else |
- // Do nothing, let the bots handle it. |
-#endif |
+ static_assert(base::is_trivially_copyable<Dest>::value, |
+ "bit_cast requires the destination type to be copyable"); |
+ static_assert(base::is_trivially_copyable<Source>::value, |
+ "bit_cast requires the source type to be copyable"); |
Dest dest; |
memcpy(&dest, &source, sizeof(dest)); |