1/*
2Copyright 2019 Glen Joseph Fernandes
3(glenjofe@gmail.com)
4
5Distributed under the Boost Software License, Version 1.0.
6(http://www.boost.org/LICENSE_1_0.txt)
7*/
8#ifndef BOOST_CORE_NVP_HPP
9#define BOOST_CORE_NVP_HPP
10
11#include <boost/core/addressof.hpp>
12#include <boost/config.hpp>
13
14namespace boost {
15namespace serialization {
16
17template<class T>
18class nvp {
19public:
20 nvp(const char* n, T& v) BOOST_NOEXCEPT
21 : n_(n)
22 , v_(boost::addressof(v)) { }
23
24 const char* name() const BOOST_NOEXCEPT {
25 return n_;
26 }
27
28 T& value() const BOOST_NOEXCEPT {
29 return *v_;
30 }
31
32 const T& const_value() const BOOST_NOEXCEPT {
33 return *v_;
34 }
35
36private:
37 const char* n_;
38 T* v_;
39};
40
41template<class T>
42inline const nvp<T>
43make_nvp(const char* n, T& v) BOOST_NOEXCEPT
44{
45 return nvp<T>(n, v);
46}
47
48} /* serialization */
49
50using serialization::nvp;
51using serialization::make_nvp;
52
53} /* boost */
54
55#define BOOST_NVP(v) boost::make_nvp(BOOST_STRINGIZE(v), v)
56
57#endif
58

source code of include/boost/core/nvp.hpp