1
0
forked from boostorg/core

Remove save and load helpers and update documentation for NVP

This commit is contained in:
Glen Fernandes
2019-09-04 20:04:27 -04:00
parent 5fb5a3e292
commit 26497003f2
3 changed files with 9 additions and 48 deletions

View File

@ -40,6 +40,7 @@ namespace boost {
template<class T>
class nvp {
public:
nvp(const char* name, T& value) noexcept;
const char* name() const noexcept;
@ -49,13 +50,7 @@ class nvp {
const T& const_value() const noexcept;
template<class A>
void save(A& archive, unsigned) const;
template<class A>
void load(A& archive, unsigned);
template<class A>
void serialize(A& archive, unsigned);
void serialize(A& archive, unsigned version);
};
template<class T>
@ -80,26 +75,22 @@ const nvp<T> make_nvp(const char* name, T& value) noexcept;
[variablelist
[[`const char* name() const noexcept;`]
[Returns the stored name pointer.]]
[Returns a pointer to the name.]]
[[`T& value() const noexcept;`]
[Returns the stored value pointer.]]
[Returns a reference to the value.]]
[[`const T& const_value() const noexcept;`]
[Returns the stored value pointer.]]
[[`template<class A> void save(A& archive, unsigned) const;`]
[Calls `archive.operator<<(const_value())`.]]
[[`template<class A> void load(A& archive, unsigned);`]
[Calls `archive.operator>>(value())`.]]
[Returns a reference to the value.]]
[[`template<class A> void serialize(A& archive,
unsigned version);`]
[Calls `save(archive, version)` if `A::is_saving` is a true type,
otherwise `load(archive, version)`.]]]
[Calls `archive.operator<<(const_value())` if `A::is_saving` is a true type,
otherwise `archive.operator>>(value())`.]]]
[endsect]
[section Traits]
[variablelist
[[`template<class T> class is_nvp;`]
[[`template<class T> struct is_nvp;`]
[Provides static constant `value` equal to true if `T` is an NVP type,
otherwise false.]]]
@ -118,7 +109,7 @@ noexcept;`]
[section Acknowledgments]
Robert Ramey originally implemented nvp in the Serialization library. Glen
Robert Ramey originally implemented NVP in the Serialization library. Glen
Fernandes implemented this new (but compatible) version in the Core library.
[endsect]

View File

@ -51,16 +51,6 @@ public:
return *v_;
}
template<class A>
void save(A& a, unsigned) const {
a.operator<<(*v_);
}
template<class A>
void load(A& a, unsigned) {
a.operator>>(*v_);
}
template<class A>
void serialize(A& a, unsigned) {
archive(a, detail::nvp_bool<A::is_saving::value>());

View File

@ -56,24 +56,6 @@ void test()
BOOST_TEST_EQ(&p.value(), &v);
}
void test_save()
{
int v = 1;
boost::nvp<int> p("name", v);
saver s(0);
p.save(s, unsigned());
BOOST_TEST_EQ(s.get(), 1);
}
void test_load()
{
int v = 1;
boost::nvp<int> p("name", v);
loader l(5);
p.load(l, unsigned());
BOOST_TEST_EQ(p.value(), 5);
}
void test_serialize()
{
int v = 1;
@ -117,8 +99,6 @@ void test_factory()
int main()
{
test();
test_save();
test_load();
test_serialize();
test_deserialize();
test_trait();