mirror of
https://github.com/USCiLab/cereal.git
synced 2025-09-22 21:09:33 +02:00
Got rid of allocator handling
This commit is contained in:
parent
b7d00eb7b7
commit
292cc8d66d
@ -30,26 +30,24 @@
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
//! Serialization for std::vectors of arithmetic (but not bool), default allocator
|
||||
//! using binary serialization, if supported
|
||||
//! Serialization for std::vectors of arithmetic (but not bool) using binary serialization, if supported
|
||||
template <class Archive, class T, class A> inline
|
||||
typename std::enable_if<traits::is_output_serializable<BinaryData<T>, Archive>()
|
||||
&& std::is_arithmetic<T>::value && !std::is_same<T, bool>::value
|
||||
&& std::is_same<A, std::allocator<T>>::value, void>::type
|
||||
&& std::is_arithmetic<T>::value && !std::is_same<T, bool>::value, void>::type
|
||||
save( Archive & ar, std::vector<T, A> const & vector )
|
||||
{
|
||||
ar( vector.size() ); // number of elements
|
||||
ar( binary_data( vector.data(), vector.size() * sizeof(T) ) );
|
||||
}
|
||||
|
||||
//! Serialization for std::vectors of arithmetic (but not bool), default allocator
|
||||
//! using binary serialization, if supported
|
||||
//! Serialization for std::vectors of arithmetic (but not bool) using binary serialization, if supported
|
||||
template <class Archive, class T, class A> inline
|
||||
typename std::enable_if<traits::is_input_serializable<BinaryData<T>, Archive>()
|
||||
&& std::is_arithmetic<T>::value && !std::is_same<T, bool>::value
|
||||
&& std::is_same<A, std::allocator<T>>::value, void>::type
|
||||
&& std::is_arithmetic<T>::value && !std::is_same<T, bool>::value, void>::type
|
||||
load( Archive & ar, std::vector<T, A> & vector )
|
||||
{
|
||||
size_t vectorSize;
|
||||
@ -59,39 +57,6 @@ namespace cereal
|
||||
ar( binary_data( vector.data(), vectorSize * sizeof(T) ) );
|
||||
}
|
||||
|
||||
//! Serialization for std::vectors of arithmetic (but not bool), special allocator
|
||||
//! using binary serialization, if supported
|
||||
template <class Archive, class T, class A> inline
|
||||
typename std::enable_if<traits::is_output_serializable<BinaryData<T>, Archive>()
|
||||
&& std::is_arithmetic<T>::value && !std::is_same<T, bool>::value
|
||||
&& !std::is_same<A, std::allocator<T>>::value, void>::type
|
||||
save( Archive & ar, std::vector<T, A> const & vector )
|
||||
{
|
||||
size_t const dataSize = std::addressof(vector.back()) - std::addressof(vector.front()) + 1;
|
||||
|
||||
ar( vector.size() ); // number of elements
|
||||
ar( dataSize ); // size of data (may be larger due to allocator strategy)
|
||||
ar( binary_data( vector.data(), dataSize * sizeof(T) ) );
|
||||
}
|
||||
|
||||
//! Serialization for std::vectors of arithmetic (but not bool), special allocator
|
||||
//! using binary serialization, if supported
|
||||
template <class Archive, class T, class A> inline
|
||||
typename std::enable_if<traits::is_input_serializable<BinaryData<T>, Archive>()
|
||||
&& std::is_arithmetic<T>::value && !std::is_same<T, bool>::value
|
||||
&& !std::is_same<A, std::allocator<T>>::value, void>::type
|
||||
load( Archive & ar, std::vector<T, A> & vector )
|
||||
{
|
||||
size_t vectorSize;
|
||||
size_t dataSize;
|
||||
ar( vectorSize,
|
||||
dataSize );
|
||||
|
||||
vector.resize( vectorSize );
|
||||
|
||||
ar( binary_data( vector.data(), dataSize * sizeof(T) ) );
|
||||
}
|
||||
|
||||
//! Serialization for non-arithmetic (and bool) vector types
|
||||
template <class Archive, class T, class A> inline
|
||||
typename std::enable_if<!traits::is_output_serializable<BinaryData<T>, Archive>()
|
||||
|
Loading…
x
Reference in New Issue
Block a user