Index: base/bit_cast.h |
diff --git a/base/bit_cast.h b/base/bit_cast.h |
index c9514bceef4d861f660aa200eaccc997c6588361..04c1957f6aca0b1d2e453cfe2e619274398b15ca 100644 |
--- a/base/bit_cast.h |
+++ b/base/bit_cast.h |
@@ -63,6 +63,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"); |
+ static_assert(std::is_trivially_copyable<Dest>::value, |
+ "bit_cast requires the destination type to be copyable"); |
+ static_assert(std::is_trivially_copyable<Source>::value, |
+ "bit_cast requires the source type to be copyable"); |
#if (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) || \ |
(defined(__clang__) && defined(_LIBCPP_VERSION))) |