Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2007-09-12 23:03:10


Try the following change.

Read the explanation in the "rationale" section.

Robert Ramey

Cory Omand wrote:
> Hello,
>
> I am trying to serialize std containers via boost::serialization, but
> I am unable to get even simple code samples to compile. I used the
> serialization test_map.cpp as a guide to arrive at the very simple
> code that follows:
>
> --- snip ---
> #include <boost/serialization/map.hpp>
> #include <boost/serialization/string.hpp>
> #include <boost/serialization/nvp.hpp>
> #include <boost/archive/xml_oarchive.hpp>
> #include <iostream>
> #include <string> // not necessary - but does no harm
> #include <map> // not necessary - but does no harm

>
> int
> main()
> {
> std::map<std::string, std::string> data;
> data.insert(std::make_pair("a", "b"));
> data.insert(std::make_pair("b", "c"));
> data.insert(std::make_pair("c", "d"));

      const std::map<std::string, std::string> & data_ref = data;
>
> boost::archive::xml_oarchive oa(std::cout);
> oa << boost::serialization::make_nvp("data", dataref);
>
> return 0;
> }
> --- snip ---
>
> Can anyone spot misuse above, or give me some clue as to why this
> won't compile?
>
> I am using boost 1.33.1, with GCC 4.1.1. If I change 'data' to be a
> simple string, serialization works, but if I use any std::container
> type (I've tried vector<string>, list<string>, and map<string,string>
> so far), I get an error of the following form:
>
> /usr/include/boost-1_33_1/boost/archive/detail/oserializer.hpp:131:
> error: invalid use of undefined type 'T3', where
> T1 = string
> T2 = list<T1>
> T3 = struct boost::serialization::extended_type_info_null<T2>
> /usr/include/boost-1_33_1/boost/serialization/type_info_implementation.hpp:26:
> error: declaration of 'T3', where
> T1 = string
> T2 = list<T1>
> T3 = struct boost::serialization::extended_type_info_null<T2>
> /usr/include/boost-1_33_1/boost/archive/detail/oserializer.hpp:132:
> error: invalid use of undefined type 'T3', where
> T1 = string
> T2 = list<T1>
> T3 = struct boost::serialization::extended_type_info_null<T2>
> /usr/include/boost-1_33_1/boost/serialization/type_info_implementation.hpp:26:
> error: declaration of 'T3', where
> T1 = string
> T2 = list<T1>
> T3 = struct boost::serialization::extended_type_info_null<T2>
>
> Any assistance would be greatly appreciated.
>
> - C.


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