Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] of nested stl containers
From: Pablo Madoery (madoerypablo_at_[hidden])
Date: 2014-03-26 15:02:33


There is an error in the code above:

the code is this:

int main()
{

list< pair<string, string> > stlStr;
pair<string, string> par1("aaa", "bbb");
stlStr.push_back(par1);

std::ofstream ofs("filename");
{
boost::archive::text_oarchive serial(ofs);
serial << stlStr;
}

std::ifstream ifs("filename");
boost::archive::text_iarchive serial2(ifs);
list<pair<string, string> > lst;
serial2 >> lst;

return 0;
}

On Wed, Mar 26, 2014 at 3:44 PM, Pablo Madoery <madoerypablo_at_[hidden]>wrote:

> I have the following code:
>
> #include <list>
> #include <utility>
> #include <vector>
> #include <string>
> #include <fstream>
> #include <boost/archive/text_oarchive.hpp>
> #include <boost/archive/text_iarchive.hpp>
> #include <boost/serialization/access.hpp>
> #include <boost/serialization/string.hpp>
> #include <boost/serialization/vector.hpp>
> #include <boost/serialization/utility.hpp>
> #include <boost/serialization/map.hpp>
> #include <boost/serialization/base_object.hpp>
>
> using namespace std;
>
> int main()
> {
>
> list< pair<string, string> > stlStr;
> pair<string, string> par1("aaa", "bbb");
> stlStr.push_back(make_pair("key", par1));
>
>
> std::ofstream ofs("filename");
> {
> boost::archive::text_oarchive serial(ofs);
> serial << stlStr;
> }
>
> std::ifstream ifs("filename");
> boost::archive::text_iarchive serial2(ifs);
> list<pair<string, string> > lst;
> serial2 >> lst;
>
> return 0;
> }
>
> that throw the following compilation error:
> error: 'class std::list<std::pair<std::basic_string<char>,
> std::basic_string<char> > >' has no member named 'serialize'.
>
> I'd like to know if I have to manually implement the serialization of this
> nested list. Because for example I haven't problems with maps that have
> inside a pair : map<string, pair<string, string> >.
>
> Thanks !
>



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