Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new in using boost serialization library.
I want to save and load data to and from STL structures using text_iarchive and text_oarchive.
I used bellow code for that:
mystruct test;
test.initial();
{
    std::ofstream ofs("filename.dat");
    boost::archive::text_oarchive ar(ofs);
    ar & test;
}
{
    std::ifstream ifs("filename.dat");
    boost::archive::text_iarchive ar(ifs);
    mystruct restored;
    ar & restored;
}


What I have tried:

On map, list, deque, set and vector there isn't any problem but on queue and stack I get following errors:
error: no matching function for call to 'save(boost::archive::text_oarchive&, const std::deque >&, const unsigned int&)'
error: no matching function for call to 'load(boost::archive::text_iarchive&, std::deque >&, const unsigned int&)'
How can I solve this problem?
Posted
Updated 27-Jan-18 19:34pm
Comments
Richard MacCutchan 27-Jan-18 11:39am    
Where do these error messages occur?
CPallini 27-Jan-18 11:42am    
Did you include the corresponding headers (e.g. "boost/serialization/stack.hpp")?

1 solution

yesterday I found out something first when I use cout for printing my structure it works Okey. but when I want to read and write from file this happens, this problem occurs only with use of stack and queue. At second, I used headers for serialization in main function before, but when I use that headers for my queue and stack class the problem solved. its wired !

when I used this order of header those errors appeared:

#include <boost/serialization/vector.hpp>
#include <boost/serialization/set.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/queue.hpp>
#include <boost/serialization/stack.hpp>
#include <boost/serialization/deque.hpp>


but when I used this problem solved:

#include <boost/serialization/vector.hpp>
#include <boost/serialization/set.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/deque.hpp>
#include <boost/serialization/queue.hpp>
#include <boost/serialization/stack.hpp>
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900