diff --git a/include/cereal/types/array.hpp b/include/cereal/types/array.hpp index 8ae2a4a0..89e42350 100644 --- a/include/cereal/types/array.hpp +++ b/include/cereal/types/array.hpp @@ -39,7 +39,7 @@ namespace cereal //! using binary serialization, if supported template inline typename std::enable_if, Archive>::value - && std::is_arithmetic::value, void>::type + && std::is_trivially_copyable::value, void>::type CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array const & array ) { ar( binary_data( array.data(), sizeof(array) ) ); @@ -49,7 +49,7 @@ namespace cereal //! using binary serialization, if supported template inline typename std::enable_if, Archive>::value - && std::is_arithmetic::value, void>::type + && std::is_trivially_copyable::value, void>::type CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array & array ) { ar( binary_data( array.data(), sizeof(array) ) ); @@ -58,7 +58,7 @@ namespace cereal //! Saving for std::array all other types template inline typename std::enable_if, Archive>::value - || !std::is_arithmetic::value, void>::type + || !std::is_trivially_copyable::value, void>::type CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array const & array ) { for( auto const & i : array ) @@ -68,7 +68,7 @@ namespace cereal //! Loading for std::array all other types template inline typename std::enable_if, Archive>::value - || !std::is_arithmetic::value, void>::type + || !std::is_trivially_copyable::value, void>::type CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array & array ) { for( auto & i : array ) diff --git a/include/cereal/types/common.hpp b/include/cereal/types/common.hpp index 4ea67e2e..29b070a2 100644 --- a/include/cereal/types/common.hpp +++ b/include/cereal/types/common.hpp @@ -36,7 +36,7 @@ namespace cereal { namespace common_detail { - //! Serialization for arrays if BinaryData is supported and we are arithmetic + //! Serialization for arrays if BinaryData is supported and we are trivially-copyable /*! @internal */ template inline void serializeArray( Archive & ar, T & array, std::true_type /* binary_supported */ ) @@ -44,7 +44,7 @@ namespace cereal ar( binary_data( array, sizeof(array) ) ); } - //! Serialization for arrays if BinaryData is not supported or we are not arithmetic + //! Serialization for arrays if BinaryData is not supported or we are not trivially-copyable /*! @internal */ template inline void serializeArray( Archive & ar, T & array, std::false_type /* binary_supported */ ) @@ -122,7 +122,7 @@ namespace cereal { common_detail::serializeArray( ar, array, std::integral_constant, Archive>::value && - std::is_arithmetic::type>::value>() ); + std::is_trivially_copyable::type>::value>() ); } } // namespace cereal diff --git a/include/cereal/types/valarray.hpp b/include/cereal/types/valarray.hpp index ed56e229..0ae4f89c 100644 --- a/include/cereal/types/valarray.hpp +++ b/include/cereal/types/valarray.hpp @@ -37,20 +37,20 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace cereal { - //! Saving for std::valarray arithmetic types, using binary serialization, if supported + //! Saving for std::valarray trivially-copyable types, using binary serialization, if supported template inline typename std::enable_if, Archive>::value - && std::is_arithmetic::value, void>::type + && std::is_trivially_copyable::value, void>::type CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::valarray const & valarray ) { ar( make_size_tag( static_cast(valarray.size()) ) ); // number of elements ar( binary_data( &valarray[0], valarray.size() * sizeof(T) ) ); // &valarray[0] ok since guaranteed contiguous } - //! Loading for std::valarray arithmetic types, using binary serialization, if supported + //! Loading for std::valarray trivially-copyable types, using binary serialization, if supported template inline typename std::enable_if, Archive>::value - && std::is_arithmetic::value, void>::type + && std::is_trivially_copyable::value, void>::type CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::valarray & valarray ) { size_type valarraySize; @@ -63,7 +63,7 @@ namespace cereal //! Saving for std::valarray all other types template inline typename std::enable_if, Archive>::value - || !std::is_arithmetic::value, void>::type + || !std::is_trivially_copyable::value, void>::type CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::valarray const & valarray ) { ar( make_size_tag( static_cast(valarray.size()) ) ); // number of elements @@ -74,7 +74,7 @@ namespace cereal //! Loading for std::valarray all other types template inline typename std::enable_if, Archive>::value - || !std::is_arithmetic::value, void>::type + || !std::is_trivially_copyable::value, void>::type CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::valarray & valarray ) { size_type valarraySize; diff --git a/include/cereal/types/vector.hpp b/include/cereal/types/vector.hpp index aee9e3f2..dfa37d7f 100644 --- a/include/cereal/types/vector.hpp +++ b/include/cereal/types/vector.hpp @@ -35,20 +35,20 @@ namespace cereal { - //! Serialization for std::vectors of arithmetic (but not bool) using binary serialization, if supported + //! Serialization for std::vectors of trivially-copyable (but not bool) using binary serialization, if supported template inline typename std::enable_if, Archive>::value - && std::is_arithmetic::value && !std::is_same::value, void>::type + && std::is_trivially_copyable::value && !std::is_same::value, void>::type CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::vector const & vector ) { ar( make_size_tag( static_cast(vector.size()) ) ); // number of elements ar( binary_data( vector.data(), vector.size() * sizeof(T) ) ); } - //! Serialization for std::vectors of arithmetic (but not bool) using binary serialization, if supported + //! Serialization for std::vectors of trivially-copyable (but not bool) using binary serialization, if supported template inline typename std::enable_if, Archive>::value - && std::is_arithmetic::value && !std::is_same::value, void>::type + && std::is_trivially_copyable::value && !std::is_same::value, void>::type CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::vector & vector ) { size_type vectorSize; @@ -58,10 +58,10 @@ namespace cereal ar( binary_data( vector.data(), static_cast( vectorSize ) * sizeof(T) ) ); } - //! Serialization for non-arithmetic vector types + //! Serialization for non-trivially-copyable vector types template inline typename std::enable_if<(!traits::is_output_serializable, Archive>::value - || !std::is_arithmetic::value) && !std::is_same::value, void>::type + || !std::is_trivially_copyable::value) && !std::is_same::value, void>::type CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::vector const & vector ) { ar( make_size_tag( static_cast(vector.size()) ) ); // number of elements @@ -69,10 +69,10 @@ namespace cereal ar( v ); } - //! Serialization for non-arithmetic vector types + //! Serialization for non-trivially-copyable vector types template inline typename std::enable_if<(!traits::is_input_serializable, Archive>::value - || !std::is_arithmetic::value) && !std::is_same::value, void>::type + || !std::is_trivially_copyable::value) && !std::is_same::value, void>::type CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::vector & vector ) { size_type size;