Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-10-01 04:47:22

Robert Ramey wrote:

> Another idea:
> How about if I added an accessor class to stl input so that you could
> write:
> class V {
> public:
> V(int i) : m_i(i) {}
> private:
> int m_i;
> private: // serialization support
> friend class boost::serialization::access;
> // accesor to grant privliges to stl serialization only
> friend class boost::serialization::stl::access;


> template<class Archive>
> void serialize(Archive& ar, unsigned version)
> {
> ar & m_i;
> }
> };
> It would seem to me that the represents the best solution
> a) I doesn't grant access to default private constructor unless I ask for
> it. b) It pretty neat and self documenting
> c) I can be implement only in the serialization of stl collections so
> it doesn't require any change to serialization library proper and
> avoids an undesirable coupling

One objection I have to this idea is that it decouples serialization library
comonent but add some dependency between serialization and user classes.
How do I know if I should add

    friend class boost::serialization::stl::access;

to a class. Naturally, I have to if I plan the serialize vectors of the
class. It's possible to add this to every class, but then it's just extra
typing. If I don't add it by default, then I'll have to add it the first
time I'm going to serialize a vector of class. So the system becames
unstable: some C++ module suddenly decides to serialize a vector of my
class, and I have to change declarations in header.

I don't know how to best address the concerns you express in other posting,
I'll try to think about it and reply. But I'll be busy till the end of this
week, so expect some delay.

- Volodya

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