I am using boost.serialization. some sample code use BOOST_SERIALIZATION_NVP in serialize method:
我正在使用boost.serialization。一些示例代码在serialize方法中使用BOOST_SERIALIZATION_NVP:
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?
1 个解决方案
#1
34
BOOST_SERIALIZATION_NVP
is a macro that expands (in your example) to:
BOOST_SERIALIZATION_NVP是一个宏(在您的示例中)扩展为:
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
make_nvp是一个包装器,其作用与直接序列化相同
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
.
除了序列化到XML存档时。 XML归档文件需要一些名称才能用于XML标记。此名称是make_nvp的字符串参数中指定的名称。
#1
34
BOOST_SERIALIZATION_NVP
is a macro that expands (in your example) to:
BOOST_SERIALIZATION_NVP是一个宏(在您的示例中)扩展为:
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
make_nvp是一个包装器,其作用与直接序列化相同
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
.
除了序列化到XML存档时。 XML归档文件需要一些名称才能用于XML标记。此名称是make_nvp的字符串参数中指定的名称。