|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2003-09-30 15:06:39
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;
V() {}
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
I believe this is the best solution and I will included it with next upload
if no one has any objection.
Robert Ramey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk