Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] Support for smart pointers?
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2009-01-29 15:59:22


Never mind, I happened to stumble across the answer. I was looking through
the unit tests for Boost.Serialization and noticed that while scoped_ptr was
not used anywhere, shared_ptr was. So I check out the header files and I see
a <boost/serialization/scoped_ptr.hpp>. And behold, I can deserialize into a
scoped_ptr!

On Thu, Jan 29, 2009 at 2:34 PM, Robert Dailey <rcdailey_at_[hidden]> wrote:

> Hi,
>
> The documentation for Boost.Serialization states that support for
> loading/saving pointers is fully supported out of the box. However, what if
> I want to use smart pointers, such a boost::scoped_ptr?
>
> Right now I believe I would have to do this:
>
> Foo* foo1;
> archive & foo1;
> boost::scoped_ptr<Foo> foo2( foo1 );
>
> I was thinking it would be convenient to avoid the extra variable (foo1)
> and do this:
>
> boost::scoped_ptr<Foo> foo2;
> archive & foo2;
>
>
> Is this possible?
>



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