Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-03-15 11:11:47


Hmmm I just compiled on my system with gcc 3.3, vc 7.1, and comeau
all without problems. I'm using the current cvs HEAD but I wouldn't
think that would make a difference:

#include <fstream>

#include <list>

#include <boost/serialization/list.hpp>

#include <boost/archive/text_oarchive.hpp>

int main(int argc, char** argv)

{

typedef std::list<int> List;

List myList;

myList.push_back(1);

myList.push_back(2);

myList.push_back(3);

myList.push_back(4);

std::ofstream ofs("archive.txt");

boost::archive::text_oarchive oa(ofs);

oa & myList;

}

Robert Ramey

Max Schoebinger wrote:
> Hi,
>
> I also tried using the & operator, but this also results in a compiler
> error:
>
> /opt/toolkits/linux32/gcc-3.3/boost-1-33-1/include/boost-1_33_1/boost/archive/detail/oserializer.hpp:108:
> error: incomplete type
> 'boost::serialization::extended_type_info_null<std::list<int,
> std::allocator<int> > >' cannot be used to name a scope
>
> What would be a minimal example for serializing a std::list<int>?
>
> Thank you for your help!
>
> Max
>
>
> Robert Ramey schrieb:
>> the << operator can only be used for "const" objects - the
>> & operator can be used for anything.
>>
>> This is explained in the "rationale" section of the documentation.
>>
>> Robert Ramey
>>
>> Max Schoebinger wrote:
>>> Hi everybody,
>>>
>>> I am new to the serialization library and encountered a simple
>>> problem which I couldn't solve. I'd like to serialize simple stl
>>> containers. A minimal example is
>>>
>>> #include <fstream>
>>> #include <list>
>>> #include <boost/serialization/list.hpp>
>>> #include <boost/archive/text_oarchive.hpp>
>>>
>>> int main(int argc, char** argv)
>>> {
>>> typedef std::list<int> List;
>>>
>>> List myList;
>>> myList.push_back(1);
>>> myList.push_back(2);
>>> myList.push_back(3);
>>> myList.push_back(4);
>>> std::ofstream ofs("archive.txt");
>>> boost::archive::text_oarchive oa(ofs);
>>> oa << myList;
>>> }
>>>
>>> This doesn't compile under Linux using gcc-3.3 and boost-1.33.1
>>> giving the following compiler error:
>>>
>>> /opt/toolkits/linux32/gcc-3.3/boost-1-33-1/include/boost-1_33_1/boost/archive/detail/oserializer.hpp:567:
>>> error: incomplete type `boost::STATIC_ASSERTION_FAILURE<false>' does
>>> not have member `value'
>>>
>>> Looking at the code at the given position hints that the type which
>>> should be serialized should be marked as track_never. I added the
>>> following command below the typedef of List
>>>
>>> BOOST_CLASS_TRACKING(List, boost::serialization::track_never)
>>>
>>> which also doesn't solve the problem...
>>>
>>> Maybe I am missing something very basic. I would be very thankful,
>>> if somebody could lift the curtain in front of my eyes ;-)
>>>
>>> Best Regards,
>>>
>>> Max


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