Added make_nvp<Archive> to elide unnecessary names

This commit is contained in:
Randolph Voorhies
2013-07-03 18:57:42 -07:00
parent 5609161e3d
commit 2dcf50a57f
5 changed files with 218 additions and 80 deletions

View File

@@ -36,6 +36,7 @@
#include <cereal/types/base_class.hpp>
#include <cereal/types/array.hpp>
#include <cereal/types/vector.hpp>
#include <cereal/types/map.hpp>
#include <cxxabi.h>
#include <sstream>
@@ -301,10 +302,15 @@ int main()
//std::stringstream os;
std::ofstream os("out.xml");
cereal::XMLOutputArchive oar( os );
oar( cereal::make_nvp("hello", 5 ) );
std::string bla("bla");
oar( bla );
auto intptr = std::make_shared<int>(99);
oar( CEREAL_NVP(intptr) );
int x = 3;
oar( CEREAL_NVP(x) );
oar( 5 );
@@ -330,6 +336,7 @@ int main()
oar.saveBinaryValue( xxx, sizeof(int)*3 );
}
if(true)
{
std::ifstream is("out.xml");
cereal::XMLInputArchive iar( is );
@@ -342,6 +349,10 @@ int main()
iar( bla );
assert( bla == "bla" );
std::shared_ptr<int> intptr;
iar( CEREAL_NVP(intptr) );
assert( *intptr == 99 );
int x;
iar( CEREAL_NVP(x) );
assert( x == 3 );