1
0
forked from boostorg/core

Add a definition for nvp_bool

This commit is contained in:
Glen Fernandes
2019-09-10 08:04:40 -04:00
parent 26497003f2
commit f52dec58c2
3 changed files with 7 additions and 8 deletions

View File

@ -50,7 +50,7 @@ public:
const T& const_value() const noexcept; const T& const_value() const noexcept;
template<class A> template<class A>
void serialize(A& archive, unsigned version); void serialize(A& archive, unsigned);
}; };
template<class T> template<class T>
@ -80,8 +80,7 @@ const nvp<T> make_nvp(const char* name, T& value) noexcept;
[Returns a reference to the value.]] [Returns a reference to the value.]]
[[`const T& const_value() const noexcept;`] [[`const T& const_value() const noexcept;`]
[Returns a reference to the value.]] [Returns a reference to the value.]]
[[`template<class A> void serialize(A& archive, [[`template<class A> void serialize(A& archive, unsigned);`]
unsigned version);`]
[Calls `archive.operator<<(const_value())` if `A::is_saving` is a true type, [Calls `archive.operator<<(const_value())` if `A::is_saving` is a true type,
otherwise `archive.operator>>(value())`.]]] otherwise `archive.operator>>(value())`.]]]

View File

@ -19,7 +19,7 @@ struct nvp_bool {
typedef bool value_type; typedef bool value_type;
typedef nvp_bool type; typedef nvp_bool type;
BOOST_STATIC_CONSTANT(bool, value = V); BOOST_STATIC_CONSTEXPR bool value = V;
BOOST_CONSTEXPR operator bool() const BOOST_NOEXCEPT { BOOST_CONSTEXPR operator bool() const BOOST_NOEXCEPT {
return V; return V;
@ -30,6 +30,9 @@ struct nvp_bool {
} }
}; };
template<bool V>
BOOST_CONSTEXPR_OR_CONST bool nvp_bool<V>::value;
} /* detail */ } /* detail */
template<class T> template<class T>

View File

@ -76,14 +76,11 @@ void test_deserialize()
void test_trait() void test_trait()
{ {
BOOST_TEST_TRAIT_TRUE((boost::is_nvp<boost::nvp<int> >));
BOOST_TEST_TRAIT_FALSE((boost::is_nvp<int>)); BOOST_TEST_TRAIT_FALSE((boost::is_nvp<int>));
BOOST_TEST_TRAIT_TRUE((boost::is_nvp<boost::nvp<int> >));
BOOST_TEST_TRAIT_TRUE((boost::is_nvp<const boost::nvp<int> >)); BOOST_TEST_TRAIT_TRUE((boost::is_nvp<const boost::nvp<int> >));
BOOST_TEST_TRAIT_FALSE((boost::is_nvp<const int>));
BOOST_TEST_TRAIT_TRUE((boost::is_nvp<volatile boost::nvp<int> >)); BOOST_TEST_TRAIT_TRUE((boost::is_nvp<volatile boost::nvp<int> >));
BOOST_TEST_TRAIT_FALSE((boost::is_nvp<volatile int>));
BOOST_TEST_TRAIT_TRUE((boost::is_nvp<const volatile boost::nvp<int> >)); BOOST_TEST_TRAIT_TRUE((boost::is_nvp<const volatile boost::nvp<int> >));
BOOST_TEST_TRAIT_FALSE((boost::is_nvp<const volatile int>));
} }
void test_factory() void test_factory()