|
Boost Users : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2004-11-26 02:34:14
"Malte Clasen" <news_at_[hidden]> wrote in message
news:co6ev1$5fm$1_at_sea.gmane.org...
> Hi,
>
> the serialization docs about shared_ptr state that you have to call
> void_cast_register to use shared_ptr:
In this case the document refers to the implementation of shared_ptr rather
than programs that use it.
>
> ----------
> 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)
>
Good call, I've corrected the document for the above.
> 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?
>
In this case the document refers to the implementation of shared_ptr rather
than programs that use it. So I think ths part is ok.
Robert Ramey
>
> 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