mirror of
https://github.com/USCiLab/cereal.git
synced 2025-10-18 01:45:52 +02:00
Making some changes on vs2013, replacing some typedefs with using statements now that those are cool
This commit is contained in:
@@ -126,24 +126,25 @@ namespace cereal
|
||||
static auto member_load(Archive & ar, T & t) -> decltype(t.load(ar))
|
||||
{ t.load(ar); }
|
||||
|
||||
/*! @name Boost Transition Layer */
|
||||
//! @{
|
||||
// versioned member serialize
|
||||
template<class Archive, class T> inline
|
||||
static auto member_serialize(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.serialize(ar, version))
|
||||
{ t.serialize(ar, version); }
|
||||
|
||||
// versioned member save
|
||||
template<class Archive, class T> inline
|
||||
static auto member_save(Archive & ar, T const & t, const std::uint32_t version ) -> decltype(t.save(ar, version))
|
||||
{ t.save(ar, version); }
|
||||
|
||||
// versioned member save (non const)
|
||||
template<class Archive, class T> inline
|
||||
static auto member_save_non_const(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.save(ar, version))
|
||||
{ t.save(ar, version); }
|
||||
|
||||
// versioned member load
|
||||
template<class Archive, class T> inline
|
||||
static auto member_load(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.load(ar, version))
|
||||
{ t.load(ar, version); }
|
||||
//! @}
|
||||
|
||||
template <class T>
|
||||
static void load_and_allocate(...)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace cereal
|
||||
/*! To ensure compatability between 32, 64, etc bit machines, we need to use
|
||||
* a fixed size type instead of size_t, which may vary from machine to
|
||||
* machine. */
|
||||
typedef uint64_t size_type;
|
||||
using size_type = uint64_t;
|
||||
|
||||
// forward decls
|
||||
class BinaryOutputArchive;
|
||||
@@ -126,12 +126,12 @@ namespace cereal
|
||||
// otherwise, we store a reference. If we were passed an array, don't
|
||||
// decay the type - keep it as an array, and then proceed as normal
|
||||
// with the RValue business
|
||||
typedef typename std::conditional<std::is_array<typename std::remove_reference<T>::type>::value,
|
||||
typename std::remove_cv<T>::type,
|
||||
typename std::decay<T>::type>::type DT;
|
||||
typedef typename std::conditional<std::is_rvalue_reference<T>::value,
|
||||
DT,
|
||||
typename std::add_lvalue_reference<DT>::type>::type Type;
|
||||
using DT = typename std::conditional<std::is_array<typename std::remove_reference<T>::type>::value,
|
||||
typename std::remove_cv<T>::type,
|
||||
typename std::decay<T>::type>::type;
|
||||
using Type = typename std::conditional<std::is_rvalue_reference<T>::value,
|
||||
DT,
|
||||
typename std::add_lvalue_reference<DT>::type>::type;
|
||||
// prevent nested nvps
|
||||
static_assert( !std::is_base_of<detail::NameValuePairCore, T>::value,
|
||||
"Cannot pair a name to a NameValuePair" );
|
||||
@@ -195,9 +195,9 @@ namespace cereal
|
||||
{
|
||||
//! Internally store the pointer as a void *, keeping const if created with
|
||||
//! a const pointer
|
||||
typedef typename std::conditional<std::is_const<typename std::remove_pointer<T>::type>::value,
|
||||
const void *,
|
||||
void *>::type PT;
|
||||
using PT = typename std::conditional<std::is_const<typename std::remove_pointer<T>::type>::value,
|
||||
const void *,
|
||||
void *>::type;
|
||||
|
||||
BinaryData( T && d, uint64_t s ) : data(d), size(s) {}
|
||||
|
||||
@@ -236,10 +236,10 @@ namespace cereal
|
||||
private:
|
||||
// If we get passed an RValue, we'll just make a local copy if it here
|
||||
// otherwise, we store a reference
|
||||
typedef typename std::decay<T>::type DT;
|
||||
typedef typename std::conditional<std::is_rvalue_reference<T>::value,
|
||||
DT,
|
||||
typename std::add_lvalue_reference<DT>::type>::type Type;
|
||||
using DT = typename std::decay<T>::type;
|
||||
using Type = typename std::conditional<std::is_rvalue_reference<T>::value,
|
||||
DT,
|
||||
typename std::add_lvalue_reference<DT>::type>::type;
|
||||
|
||||
public:
|
||||
SizeTag( T && sz ) : size(const_cast<Type>(sz)) {}
|
||||
@@ -271,17 +271,17 @@ namespace cereal
|
||||
template <class Key, class Value>
|
||||
struct MapItem
|
||||
{
|
||||
typedef typename std::decay<Key>::type DecayKey;
|
||||
typedef typename std::conditional<
|
||||
using DecayKey = typename std::decay<Key>::type;
|
||||
using KeyType = typename std::conditional<
|
||||
std::is_rvalue_reference<Key>::value,
|
||||
DecayKey,
|
||||
typename std::add_lvalue_reference<DecayKey>::type>::type KeyType;
|
||||
typename std::add_lvalue_reference<DecayKey>::type>::type;
|
||||
|
||||
typedef typename std::decay<Value>::type DecayValue;
|
||||
typedef typename std::conditional<
|
||||
using DecayValue = typename std::decay<Value>::type;
|
||||
using ValueType = typename std::conditional<
|
||||
std::is_rvalue_reference<Value>::value,
|
||||
DecayValue,
|
||||
typename std::add_lvalue_reference<DecayValue>::type>::type ValueType;
|
||||
typename std::add_lvalue_reference<DecayValue>::type>::type;
|
||||
|
||||
//! Construct a MapItem from a key and a value
|
||||
/*! @internal */
|
||||
|
||||
@@ -3134,3 +3134,97 @@ BOOST_AUTO_TEST_CASE( json_unordered_loads )
|
||||
{
|
||||
test_unordered_loads<cereal::JSONInputArchive, cereal::JSONOutputArchive>();
|
||||
}
|
||||
|
||||
// ######################################################################
|
||||
struct VersionStructMS
|
||||
{
|
||||
bool x;
|
||||
std::uint32_t v;
|
||||
template <class Archive>
|
||||
void serialize( Archive & ar, std::uint32_t const version )
|
||||
{
|
||||
ar( x );
|
||||
std::cerr << "VersionStructMS " << version << std::endl;
|
||||
v = version;
|
||||
}
|
||||
};
|
||||
|
||||
struct VersionStructMSP
|
||||
{
|
||||
uint8_t x;
|
||||
std::uint32_t v;
|
||||
template <class Archive>
|
||||
void save( Archive & ar, std::uint32_t const version ) const
|
||||
{
|
||||
ar( x );
|
||||
std::cerr << "VersionStructMSP Save " << version << std::endl;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
void load( Archive & ar, std::uint32_t const version )
|
||||
{
|
||||
ar( x );
|
||||
v = version;
|
||||
std::cerr << "VersionStructMSP Load " << version << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
CEREAL_CLASS_VERSION( VersionStructMSP, 33 )
|
||||
|
||||
template <class IArchive, class OArchive>
|
||||
void test_versioning()
|
||||
{
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
|
||||
for(size_t i=0; i<100; ++i)
|
||||
{
|
||||
VersionStructMS o_MS = {random_value<uint8_t>(gen) % 2 ? true : false, -1};
|
||||
VersionStructMSP o_MSP = {random_value<uint8_t>(gen), -1};
|
||||
|
||||
std::ostringstream os;
|
||||
{
|
||||
OArchive oar(os);
|
||||
OArchive oar2(std::cout);
|
||||
oar( o_MS );
|
||||
oar( o_MSP );
|
||||
oar2( o_MS );
|
||||
oar2( o_MSP );
|
||||
}
|
||||
|
||||
decltype(o_MS) i_MS;
|
||||
decltype(o_MSP) i_MSP;
|
||||
|
||||
std::istringstream is(os.str());
|
||||
{
|
||||
IArchive iar(is);
|
||||
iar( i_MS );
|
||||
iar( i_MSP );
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL(o_MS.x, i_MS.x);
|
||||
BOOST_CHECK_EQUAL(i_MS.v, 0);
|
||||
BOOST_CHECK_EQUAL(o_MSP.x, i_MSP.x);
|
||||
BOOST_CHECK_EQUAL(i_MSP.v, 33);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( binary_versioning )
|
||||
{
|
||||
test_versioning<cereal::BinaryInputArchive, cereal::BinaryOutputArchive>();
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( portable_binary_versioning )
|
||||
{
|
||||
test_versioning<cereal::PortableBinaryInputArchive, cereal::PortableBinaryOutputArchive>();
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( xml_versioning )
|
||||
{
|
||||
test_versioning<cereal::XMLInputArchive, cereal::XMLOutputArchive>();
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( json_versioning )
|
||||
{
|
||||
test_versioning<cereal::JSONInputArchive, cereal::JSONOutputArchive>();
|
||||
}
|
||||
@@ -66,20 +66,20 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>E:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Boost\lib\x64;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>E:\Boost\lib\x64;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>E:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Boost\lib\x64;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>E:\Boost\lib\x64;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
||||
@@ -66,18 +66,18 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>E:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>E:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
||||
@@ -66,20 +66,20 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>E:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Boost\lib\x64;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>E:\Boost\lib\x64;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>E:\Boost\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(SolutionDir)\..\include;C:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\Boost\lib\x64;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)\..\include;E:\Boost\include\boost-1_55;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>E:\Boost\lib\x64;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -87,6 +87,7 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@@ -113,6 +114,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@@ -128,6 +130,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
||||
Reference in New Issue
Block a user