Boost logo

Boost Users :

Subject: Re: [Boost-users] [Serialization] shared_ptr to const object
From: elizabeta petreska (elizabeta.petreska_at_[hidden])
Date: 2009-12-21 05:27:39


Hello again
I just want to say that I managed to solve this problem without creating a
temporary , thanks to this thread :
http://old.nabble.com/(de)serializing-map%3Cconst-A*%3E-to5538474.html#a5596607<http://old.nabble.com/%28de%29serializing-map%3Cconst-A*%3E-to5538474.html#a5596607>

And here it is what I have got in my problem :

    boost::shared_ptr<const TT> jj(new TT(5));

    {
        boost::archive::xml_oarchive oa(ofs);
        oa & BOOST_SERIALIZATION_NVP(jj);
    }

    boost::shared_ptr<const TT> rjj;

    {
        void* xptr=&rjj;
        boost::shared_ptr<TT> *xxptr;
        xxptr=static_cast< boost::shared_ptr<TT> * > (xptr);
        boost::archive::xml_iarchive ia(ifs);
        ia & BOOST_SERIALIZATION_NVP(*xxptr);
    }

On Sun, Dec 20, 2009 at 3:59 PM, Steven Watanabe <watanabesj_at_[hidden]>wrote:

> AMDG
>
>
> elizabeta petreska wrote:
>
>> Thank you for the reply.
>> This works!!! , but it creates a temporary. I was thinking how to cast the
>> constness away, without making temporary object. I gess know at least I
>> have
>> one possible solution, althgough not complete happy with it :)
>>
>>
>
> You can't avoid the temporary. Actually, I think the
> serialization library should handle this automatically,
> since its perfectly safe.
>
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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