Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-09-22 11:17:34


Just a tiny note reqarding this equivalence question.

One question that comes up again and again is that of const class members.

struct X {
    const int m_i;
    int m_j;
   X(i) : m_i(i){}
};

Some users want to use:

template<class Archive>
void serialize(Archive & ar, X & x, const unsigned int version){
    ar & const_cast<int &>(m_i);
    ar & m_j;
}

while others believe the above is incorrect and use:

template<class Archive>
void serialize(Archive & ar, X & x, const unsigned int version){
    ar & m_j;
}

while still others use save/load_construct_data(...)

Is the loaded version going to be "==" to the saved version?
Depends upon how "==" is implemented for X. Is the loaded
version "equivalent" ?

Regardless of the answer to these questions, I know that the
serialization library is used to user's satisfaction by users who
have differing answers to these questions. At first I thought
I was going to have to impose a answers to these questions
in order to finish the implementation. But since that turned
out to be unnecessary, I just left it at the discretion of the user.

This has left somethings ambiguous, but it has permited me to
actually finish the package to the satisfaction of a varied group
of users.

Robert Ramey


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