Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-01-17 17:12:30


Try the following change - If this does it - read the rationale about using
const with serialization.

Robert Ramey

Joseph Turian wrote:
> Hi Robert and everyone,
>
> Thank you for explaining to me about BOOST_STRONGTYPE. I'll let you
> know how that goes for me. And thank you for being so patient and
> trying to help me get serialization working in my program.
>
> In the meantime, I'm experiencing a much simpler problem. Although I
> can serialize classes of the form boost::shared_ptr<T>, where T is a
> class I've defined, I get compilation errors if I try to serialize a
> boost::shared_ptr<int>.
>
> How can I resolve this?
>
> Code snippet:
> -----------------------------------------------
> #include <iostream>
> #include <fstream>
>
> #include <boost/shared_ptr.hpp>
> #include <boost/archive/text_oarchive.hpp>
> #include <boost/archive/text_iarchive.hpp>
> #include <boost/serialization/base_object.hpp>
> #include <boost/serialization/utility.hpp>
> #include <boost/serialization/shared_ptr.hpp>
>
> int main() {
> std::ofstream ofs("archive");
> boost::archive::text_oarchive oa(ofs);
>
> //boost::shared_ptr<int> i;
         const boost::shared_ptr<int> i;
> oa << i;
>
> return 0;
> }
> -----------------------------------------------


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