|
Boost : |
From: troy d. straszheim (troy_at_[hidden])
Date: 2005-10-10 00:21:04
On Sun, Oct 09, 2005 at 02:15:44PM -0700, Robert Ramey wrote:
> With this approach you would make one fast_oarchive adaptor class
> and one small and trivial *.hpp file for each archive it is adapted to.
Hey,
Quick question. The fast_archive example has a function template
save_override() that sends calls that aren't otherwise overridden in
derived_t back to base_t:
template<class Base>
class fast_oarchive_impl :
public Base
{
// fall through to Base for any overrides not specified here
template<class T>
void save_override(T & t, BOOST_PFTO int){
Base::save_override(t, 0);
}
// custom specializations
void save_override(const std::vector<int> & t, int){
save_binary(t, sizeof(int) * t.size());
}
};
And I've done this for a few archive types. Works fine. The
portable_binary_archive example, does the same thing, except it does
so for save(), like this:
class portable_binary_oarchive :
public boost::archive::binary_oarchive_impl<portable_binary_oarchive>
{
typedef portable_binary_oarchive derived_t;
typedef boost::archive::binary_oarchive_impl<portable_binary_oarchive>
base_t;
// default fall through for any types not specified here
template<class T>
void save(const T & t){
base_t::save(t);
}
void save(const unsigned int t){
save_impl(t);
}
};
Which I've also used. AFAICT, I could do what I've needed to do so
far either way. What's the difference? Apologies in advance if I've
missed something in the docs.
-t
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk