Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-04-11 11:23:20


The following "blunt instrument" will make things work - though I'm not sure
that its not a little tooo crude. That is it will still prevent your
destructor
from getting called via delete - though it could now be called via
checked_delete.

Robert Ramey

Mikko Vainio wrote:
> Dear Sirs,
>
> Does anyone have a working example of serialization of shared_ptrs
> with non-default deleter and factory construction as described in
> http://www.boost.org/libs/smart_ptr/sp_techniques.html#preventing_delete?
>
>
> The code below (correctly) triggers error in boost/checked_delete.hpp
> because the destructor of class X is private.
>
>
> #include <iostream>
> #include <fstream>
> #include <boost/archive/text_oarchive.hpp>
> #include <boost/archive/text_iarchive.hpp>
> #include <boost/serialization/export.hpp>
> #include <boost/serialization/shared_ptr.hpp>
> #include <boost/shared_ptr.hpp>
>
>
> class X
> {
> private:
>
        template<class T> friend inline void boost::checked_delete(T * x);

> ~X();
>


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