[/ Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com) Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) ] [section:nvp nvp] [section Overview] The header provides the class template `boost::nvp` that pairs a name (`const char*`) with the address of a value (`T*`). It is the new implementation of the NVP type previously provided by the Boost Serialization library. This type now lives in the Core library so that other Boost libraries can support named value serialization without taking a dependency on the Serialization library. [endsect] [section Examples] The following snippet shows use in a member serialize function: ``` template void serialize(A& archive, unsigned) { archive & boost::make_nvp("x", x_) & boost::make_nvp("y", y_); } ``` [endsect] [section Reference] ``` namespace boost { template class nvp { nvp(const char* name, T& value) noexcept; const char* name() const noexcept; T& value() const noexcept; const T& const_value() const noexcept; template void save(A& archive, unsigned) const; template void load(A& archive, unsigned); template void serialize(A& archive, unsigned); }; template struct is_nvp; template const nvp make_nvp(const char* name, T& value) noexcept; } /* boost */ ``` [section Constructors] [variablelist [[`nvp(const char* name, T& value) noexcept;`] [Initializes the stored name pointer with `name` and the value pointer with `addressof(value)`.]]] [endsect] [section Members] [variablelist [[`const char* name() const noexcept;`] [Returns the stored name pointer.]] [[`T& value() const noexcept;`] [Returns the stored value pointer.]] [[`const T& const_value() const noexcept;`] [Returns the stored value pointer.]] [[`template void save(A& archive, unsigned) const;`] [Calls `archive.operator<<(const_value())`.]] [[`template void load(A& archive, unsigned);`] [Calls `archive.operator>>(value())`.]] [[`template void serialize(A& archive, unsigned version);`] [Calls `save(archive, version)` if `A::is_saving` is a true type, otherwise `load(archive, version)`.]]] [endsect] [section Traits] [variablelist [[`template class is_nvp;`] [Provides static constant `value` equal to true if `T` is an NVP type, otherwise false.]]] [endsect] [section Functions] [variablelist [[`template const nvp make_nvp(const char* name, T& value) noexcept;`] [Returns `nvp(name, value)`.]]] [endsect] [endsect] [section Acknowledgments] Robert Ramey originally implemented nvp in the Serialization library. Glen Fernandes implemented this new (but compatible) version in the Core library. [endsect] [endsect]