I'm including serialization in my library and am running into problems.
One of my class include an std::auto_ptr std::string
I'm including
#include to handle the string
serialization
i downloaded the serialization example for an auto_ptr and modified
it to allow for XML serialization (see end of email).
But when i compile get the following error saying:
error: 'struct std::basic_string' has no member named 'serialize'
If i replace the std::auto_ptr std::string with just std::string it
works, so i assume something is wrong with my auto_ptr code
Feel free to ask me more question or send me beginners advice as i'm
just beginning with BOOST.
Thanks
auto_ptrSerialization.hpp:
#include <list>
#include <memory>
#include <fstream>
#include // std::autoptr inteface wrong in dinkumware
#include
#include
#include
#include
#include
namespace boost {
namespace serialization {
/////////////////////////////////////////////////////////////
// implement serialization for auto_ptr<T>
// note: this must be added to the boost namespace in order to
// be called by the library
template
inline void save(
Archive & ar,
const std::auto_ptr<T> &t,
const unsigned int file_version
){
// only the raw pointer has to be saved
// the ref count is rebuilt automatically on load
T *objectPtr = t.get();
ar << BOOST_SERIALIZATION_NVP(objectPtr);
}
template
inline void load(
Archive & ar,
std::auto_ptr<T> &t,
const unsigned int file_version
){
T *objectPtr;
ar >> BOOST_SERIALIZATION_NVP(objectPtr);
// note that the reset automagically maintains the
reference count
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
t.release();
t = std::auto_ptr<T>(objectPtr);
#else
t.reset(objectPtr);
#endif
}
// split non-intrusive serialization function member into
separate
// non intrusive save/load member functions
template
inline void serialize(
Archive & ar,
std::auto_ptr<T> &t,
const unsigned int file_version
){
split_free(ar, t, file_version);
}
} // namespace serialization
} // namespace boost
Best,
Olivier Destrebecq
olivierd@real.com