2 Copyright 2019 Glen Joseph Fernandes
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
13 The header <boost/core/nvp.hpp> provides the class template `boost::nvp` that
14 pairs a name (`const char*`) with the address of a value (`T*`). It is the new
15 implementation of the NVP type previously provided by the Boost Serialization
16 library. This type now lives in the Core library so that other Boost libraries
17 can support named value serialization without taking a dependency on the
18 Serialization library.
24 The following snippet shows use in a member serialize function:
28 void serialize(A& archive, unsigned)
30 archive & boost::make_nvp("x", x_) & boost::make_nvp("y", y_);
44 nvp(const char* name, T& value) noexcept;
46 const char* name() const noexcept;
48 T& value() const noexcept;
50 const T& const_value() const noexcept;
54 const nvp<T> make_nvp(const char* name, T& value) noexcept;
58 #define BOOST_NVP(object) ``['see below]``
61 [section Constructors]
64 [[`nvp(const char* name, T& value) noexcept;`]
65 [Initializes the stored name pointer with `name` and the value pointer with
66 `addressof(value)`.]]]
73 [[`const char* name() const noexcept;`]
74 [Returns a pointer to the name.]]
75 [[`T& value() const noexcept;`]
76 [Returns a reference to the value.]]
77 [[`const T& const_value() const noexcept;`]
78 [Returns a reference to the value.]]]
85 [[`template<class T> const nvp<T> make_nvp(const char* name, T& value)
87 [Returns `nvp<T>(name, value)`.]]]
94 [[`#define BOOST_NVP(object) see below`]
95 [Expands to `boost::make_nvp(BOOST_STRINGIZE(object), object)`.]]]
103 Robert Ramey originally implemented NVP in the Serialization library. Glen
104 Fernandes implemented this new (but compatible) version in the Core library.