Closed k-vernooy closed 4 years ago
Hi,
Instead of:
auto deserializer = [&ar]<typename U>() { U u; ar & u; return u; };
you can use something like:
template<class Archive>
class deserializer {
public:
deserializer(Archive& ar): m_ar(ar) {
}
template<typename T>
T operator()() {
T t;
m_ar & t;
return t;
}
private:
Archive& m_ar;
};
Thibaut
Thanks, this worked for me!
I'm looking to serialize an ordered-map with
boost_serialization
.I have seen the below code for splitting into save and load, and using the serialize/deserialize methods of ordered_map, however being unfamiliar with lambdas I am not sure how to adapt this to work with C++11 or C++14.
How would this be done without using templated parameters in the deserializer lambda?