mirror of
https://github.com/USCiLab/cereal.git
synced 2025-10-18 01:45:52 +02:00
Added a MapItem to wrap key/value pairs
This commit is contained in:
19
sandbox.cpp
19
sandbox.cpp
@@ -299,9 +299,9 @@ int main()
|
||||
assert(e_in == e_out);
|
||||
|
||||
{
|
||||
//std::stringstream os;
|
||||
std::ofstream os("out.xml");
|
||||
cereal::XMLOutputArchive oar( os );
|
||||
//cereal::XMLOutputArchive oar( std::cout );
|
||||
|
||||
oar( cereal::make_nvp("hello", 5 ) );
|
||||
|
||||
@@ -311,6 +311,15 @@ int main()
|
||||
auto intptr = std::make_shared<int>(99);
|
||||
oar( CEREAL_NVP(intptr) );
|
||||
|
||||
std::map<std::string, int> map1 =
|
||||
{
|
||||
{"one", 1},
|
||||
{"two", 2},
|
||||
{"three", 3}
|
||||
};
|
||||
|
||||
oar( CEREAL_NVP(map1) );
|
||||
|
||||
int x = 3;
|
||||
oar( CEREAL_NVP(x) );
|
||||
oar( 5 );
|
||||
@@ -353,6 +362,14 @@ int main()
|
||||
iar( CEREAL_NVP(intptr) );
|
||||
assert( *intptr == 99 );
|
||||
|
||||
std::map<std::string, int> map1;
|
||||
|
||||
iar( CEREAL_NVP(map1) );
|
||||
assert( map1["one"] == 1 );
|
||||
assert( map1["two"] == 2 );
|
||||
assert( map1["three"] == 3 );
|
||||
|
||||
|
||||
int x;
|
||||
iar( CEREAL_NVP(x) );
|
||||
assert( x == 3 );
|
||||
|
||||
Reference in New Issue
Block a user