Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2003-10-12 22:50:17

>Your list omits the main motivation and benefit, ie support for
>non-intrusive serialisation of standard containers. I would argue that the
>serialisation fails to fulfill its design objectives without it. The
>alternatives involve either providing a default constructor, or a friend
>declaration, or rewriting the container serialisation functions for each T.

I'm sorry I don't see a difference. Your function:

> template<class Archive ar, class T>
> T *load_construct(Archive & ar, void * pt, unsigned int file_version)
> {
> T *t = new( pt ) T();
> try {
> ar >> *t;
> } catch (...) {
> t->T::~T();
> throw;
> }
> return t;

has the same limitations as the current system.

a) if the default constructor is private - a friend declaration will be necessary
- otherwise not.
b) if there is no default constructor - this function will have to be overridden
for each T without a default constructor

But - . In the current system - collection loading will have to be overridden
for each T as well.

So, at long last, I believe I see the motivation of factoring out "load-construct" so that
for classes without a default constructor we don't have to override in two places.
I will consider this some more.

Robert Ramey

Boost list run by bdawes at, gregod at, cpdaniel at, john at