Boost logo

Boost Users :

Subject: [Boost-users] [serialization] of nested stl containers
From: Pablo Madoery (madoerypablo_at_[hidden])
Date: 2014-03-26 14:44:01

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, kalb at, bjorn.karlsson at, gregod at, wekempf at