Boost logo

Boost Users :

Subject: [Boost-users] [serialization] Storing something that could be primitive or non-default constructable.
From: Noah Roberts (roberts.noah_at_[hidden])
Date: 2011-07-13 17:30:24


template < typename T >
struct storing
{
   storing(T const& t) : val(t) {}
   T val;
};

namespace boost { namespace serialization {

template < typename Archive, typename T >
void save_construct_data(Archive & ar, storing<T> const* ptr, unsigned
int const)
{
   // what to put here?
}

template < typename Archive, typename T >
void load_construct_data(Archive & ar, storing<T> * ptr, unsigned int const)
{
  // what here?
}
}}

If I try to store val as a pointer then I can't instantiate with
anything serialization considers "primitive". For instance, if I try to
serialize a storing<std::string> then I'll get errors about std::string
not having a serialization routine even if I include
boost/serialization/string.hpp.

If I try to load into a temporary variable then I run into the problem
of having to construct one, and sometimes I need extra information to do
so (I have the serialization routines dealing with this in such cases).

Any ideas?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net