I know we can use boost::serialization for std::vector , list ,map etc as long as I include the corresponding boost header file like:
#include <boost/serialization/list.hpp>
But how could I use boost::serialization for std::stack ?
Thanks
I know we can use boost::serialization for std::vector , list ,map etc as long as I include the corresponding boost header file like:
#include <boost/serialization/list.hpp>
But how could I use boost::serialization for std::stack ?
Thanks
I know this is old, but I recently came across this problem. I was not satisfied with the solution of using std::deque because I really needed only a stack interface. Currently, boost support serialization of std::stack this by including these header files in this order
#include "boost/serialization/deque.hpp"
#include "boost/serialization/stack.hpp"
A complete example would look something like:
#include <string>
#include <stack>
#include "boost/archive/text_oarchive.hpp"
#include "boost/archive/text_iarchive.hpp"
#include "boost/serialization/deque.hpp"
#include "boost/serialization/stack.hpp"
struct s
{
std::stack<std::string> stack;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & stack;
}
};
Replace
std::stack
withstd::deque
and include: