From 2eaba7d6d1c359556308d8805e27495509e2854a Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Sun, 26 Aug 2018 02:08:51 -0400 Subject: [PATCH] Make empty_value trivial if T is trivial --- include/boost/core/empty_value.hpp | 16 ++++++++++++++-- test/empty_value_test.cpp | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/boost/core/empty_value.hpp b/include/boost/core/empty_value.hpp index 8853588..b67d42c 100644 --- a/include/boost/core/empty_value.hpp +++ b/include/boost/core/empty_value.hpp @@ -43,7 +43,13 @@ struct empty_init_t { }; template::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 empty_value : 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) diff --git a/test/empty_value_test.cpp b/test/empty_value_test.cpp index d7261b6..7c90594 100644 --- a/test/empty_value_test.cpp +++ b/test/empty_value_test.cpp @@ -34,7 +34,7 @@ void test_bool() { const boost::empty_value v1(boost::empty_init_t(), true); BOOST_TEST(v1.get()); - boost::empty_value v2; + boost::empty_value v2 = boost::empty_init_t(); BOOST_TEST(!v2.get()); v2 = v1; BOOST_TEST(v2.get());