|
Boost Users : |
From: Malte Clasen (news_at_[hidden])
Date: 2004-11-26 00:28:58
Hi,
the serialization docs about shared_ptr state that you have to call
void_cast_register to use shared_ptr:
----------
This indicates that we're not quite done. [...] In this case we need
only the latter function so we can replace the base object serialization
with:
// register the relationship between each derived class
// its polymorphic base
void_cast_register<
boost::detail::sp_counted_base,
boost::detail::sp_counted_base_impl<P, D>
>();
----------
(http://boost.org/libs/serialization/doc/shared_ptr.html)
There are two issues with this:
a) The actual void_cast_register declaration has its parameters in the
reverse order:
----------
template<class Derived, class Base>
inline BOOST_DLLEXPORT const void * void_cast_register(
const Derived * /* dnull = NULL */,
const Base * /* bnull = NULL */
) BOOST_USED;
----------
(void_cast.hpp)
b) It doesn't seem to work either way, although there are different
exceptions in both cases. The demo_shared_ptr.cpp doesn't even call it,
instead the following is used:
----------
oa.register_type(
static_cast<
boost::detail::sp_counted_base_impl<
B *, boost::checked_deleter<B>
> *
>(NULL)
----------
(demo_shared_ptr.cpp)
This one actually works, the use counter is properly updated. So I guess
the documentation is outdated, isn't it?
Malte
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net