|
Boost : |
From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2004-04-25 17:32:41
"Jeff Flinn" <TriumphSprint2000_at_[hidden]> wrote:
> While the current methods for Free Functions and Splitting save/load
methods
> are certainly understandable and work. It would be nice to be able
> (partial)specialize the "serialize" function base on its IO type. It would
> also be nice to utilize enable_if to generate different code when the
> serialize function is instantiated for input/output archives. This would
> allow compile time constructs similar to mfc's runtime Ar.IsLoad().
>
template<typename Archive>
bool is_saving(const Archive& arch) {
return boost::is_base_and_derived<boost::archive::basic_oarchive,
Archive>::value;
}
Can be used like:
template<typename Archive>
void serialize(Archive & ar, const unsigned int version) {
ar & value_1;
...
ar & value_n
if (is_saving(ar)) {
...
} else {
..
}
ar & value_n+1;
...
}
/Pavel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk