Boost logo

Boost :

From: Andy Tompkins (atompkins_at_[hidden])
Date: 2007-11-16 10:20:38


Hi,

If I create a new class, my_class, am I allowed to mark it as follows:

BOOST_CLASS_IMPLEMENTATION
  ( my_class
  , boost::serialization::primitive_type
  )

The comments in level.hpp say that it won't call serialization code,
thus I believe (and experience) that I don't need to provide either:

template<class Archive>
void my_class::serialize(Archive &ar, const unsigned int version)
or
template<class Archive>
void serialize(Archive &ar, my_class &t, const unsigned int version)

The comments also say that 'It presumes a member function or template in
the archive class that can handle this type.' Does this mean that
current archives (text, xml, and binary) are not able to use new
primitive types without altering the archive to handle the new
primitive?

As I try it, both the text and xml archives use stream operators to
convert my_class to a string and archive that. The binary archive casts
my_class to a void* and outputs sizeof(my_class) bytes to the archive.
It this expected behavior?

Thanks,
  Andy.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk