Boost logo

Boost :

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

You've pointed out that the default serializaiton of a collection
invokes the default constructor for an object. If this
default constructor is private, the program won't
compile as the current serialization library doesn't
have friend access and doesn't invoke the
default constructor through the serialization
accessor class.

Of course you can make the load function a friend

You argued that this was bothersome and I agreed
to address it. Now that I've spent some more time
looking at it - I want to change my mind (again!).
It turns out that the way I wanted to implement it
though simple, implies and extra copy of the
newly constructed item. This means every one
would have to pay for it just to address a
very rare situation. So I want to leave things as they

My argument is:

a) Making the change would a performance penalty.
b) The template that invokes the private constructor
can be declared a friend if necessary.
c) This situation should be very rare.

My argument for c) above is recounted in
Basically I argue that if we want to make a constructor
private - it's to prohibit anyone from creating an invalid
object. I understand that there can occasions when
one needs to do this - but I argue that these are very
rare occasions. On such occasions we can add an
extra friend declaration.

I know this is rare occurence for me, If I'm wrong about
this being a rare occurence in general, it might be
interesting to know what I'm missing here.

Robert Ramey

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