c++ - serializing classes using boost serialization without changing the class -


this piece of code has written every time make class i.e.from template<class archive> ar & boost_serialization_nvp(b) . how can make short? , how can serialize stl containers ?

 class employee   {  private:           friend class boost::serialization::access;       template<class archive> void serialize(archive & ar,               const unsigned int version)        {           ar & boost_serialization_nvp(a);           ar & boost_serialization_nvp(b);       }        int a;      int b;   public:       employee(int a, int b)       {           this->a = a;           this->b = b;      }   };  

i suggest start documentation :)

stl containers serializable when include relevant header:

#include <boost/serialization/map.hpp> #include <boost/serialization/string.hpp> 

a host of other stuff supported out of box.

you could make generic wrappers types have been made "reflectible" other means (e.g. fusion sequences, qt qobjects etc.)


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -