Boost logo

Boost Users :

Subject: [Boost-users] Boost.Serialization how to use serialize without nvp
From: gast128 (gast128_at_[hidden])
Date: 2016-03-23 07:45:47


Hello all,

we basically have a setup like this:

#ifdef _DEBUG
template <typename T>
struct Wrapper
{
   T m_value;
};
#define HANDLE(T) Wrapper<T>
#else
#define HANDLE(T) T
#endif

We want archives the same for debug and release. So I tried a couple of things:
* use primitive_type: This doesn't work if the type T is a string. Basically
it doesn't come in the 'load(std::wstring &ws)' anymore, since it now routes
to operator<< and then all kinds of nasty thing happens for xml archives.
* overload serialize. This is also a failure, since it expects somehow a
nvp, which I tried to circumvent since then there is a difference between
archives in debug or release. Using 'is_wrapper' doesn't help either

template <class Archive, typename T>
void serialize(Archive& ar, Wrapper<T>& r, const unsigned int)
{
   ar & r.m_value; // static assert in basic_xml_iarchive::load_override
}

somehow I must specify raw storage in the serialize function, but
load_override and its siblings are all protected.

Anyone?


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