1
0
forked from boostorg/core

Make empty_value<T> trivial if T is trivial

This commit is contained in:
Glen Fernandes
2018-08-26 02:08:51 -04:00
parent a05906fd44
commit 2eaba7d6d1
2 changed files with 15 additions and 3 deletions

View File

@ -43,7 +43,13 @@ struct empty_init_t { };
template<class T, unsigned = 0, bool = use_empty_value_base<T>::value>
class empty_value {
public:
empty_value()
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
empty_value() = default;
#else
empty_value() { }
#endif
empty_value(empty_init_t)
: value_() { }
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
@ -79,7 +85,13 @@ template<class T, unsigned N>
class empty_value<T, N, true>
: T {
public:
empty_value()
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
empty_value() = default;
#else
empty_value() { }
#endif
empty_value(empty_init_t)
: T() { }
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)

View File

@ -34,7 +34,7 @@ void test_bool()
{
const boost::empty_value<bool> v1(boost::empty_init_t(), true);
BOOST_TEST(v1.get());
boost::empty_value<bool> v2;
boost::empty_value<bool> v2 = boost::empty_init_t();
BOOST_TEST(!v2.get());
v2 = v1;
BOOST_TEST(v2.get());