I am using boost.serialization. some sample code use BOOST_SERIALIZATION_NVP in serialize method:
template<class Archive> void save(Archive & ar, const unsigned int version) const { ar & BOOST_SERIALIZATION_NVP(_from_prop); }
I tried to google its functionality but nothing useful is found. what is the diff between
ar & BOOST_SERIALIZATION_NVP(_from_prop)
and
ar & _from_prop?
BOOST_SERIALIZATION_NVP
is a macro that expands (in your example) to:
template<class Archive> void save(Archive & ar, const unsigned int version) const { ar & boost::serialization::make_nvp("_from_prop", _from_prop) }
make_nvp
is a wrapper that acts the same as serializing directly as by
ar & _from_prop;
except when serializing to an XML archive. An XML archive needs some name to be used for the XML tag. This name is the name specified in the string parameter to make_nvp
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With