diff --git a/doc/1A_on_performance.qbk b/doc/1A_on_performance.qbk index 6bb68ce..579e0b2 100644 --- a/doc/1A_on_performance.qbk +++ b/doc/1A_on_performance.qbk @@ -10,7 +10,7 @@ Technical details aside, the memory layout of `optional` for a generic `T` is std::aligned_storage_t _storage; }; -Lifetime of the `T` inside `_storage` is manually controlled with placement-`new`s and pseudo-destructor calls. However, for trivial `T`s we use a different way of storage, by simply holding a `T`: +Lifetime of the `T` inside `_storage` is manually controlled with placement-`new`s and pseudo-destructor calls. However, for scalar `T`s we use a different way of storage, by simply holding a `T`: template class optional @@ -19,7 +19,7 @@ Lifetime of the `T` inside `_storage` is manually controlled with placement-`new T _storage; }; -We call it a ['direct] storage. This makes `optional` a trivially-copyable type for trivial `T`s. This only works for compilers that support defaulted functions and type traits. On compilers without defaulted functions we still use the direct storage, but `optional` is no longer recognized as trivially-copyable. On compilers that do not fully support type traits, we still use the direct storage for scalar types, but we leave the programmer a way of customizing her type, so that it is reconized by `optional` as trivial, by specializing type trait `boost::opitonal_config::is_type_trivial`: +We call it a ['direct] storage. This makes `optional` a trivially-copyable type for scalar `T`s. This only works for compilers that support defaulted functions. On compilers without defaulted functions we still use the direct storage, but `optional` is no longer recognized as trivially-copyable. Apart from scalar types, we leave the programmer a way of customizing her type, so that it is reconized by `optional` as candidate for optimized storage, by specializing type trait `boost::opitonal_config::optional_uses_direct_storage_for`: struct X // not trivial { @@ -28,7 +28,7 @@ We call it a ['direct] storage. This makes `optional` a trivially-copyable ty namespace boost { namespace optional_config { - template <> struct is_type_trivial : boost::true_type {}; + template <> struct optional_uses_direct_storage_for : boost::true_type {}; }} diff --git a/doc/91_relnotes.qbk b/doc/91_relnotes.qbk index 0c18f93..ba94ef6 100644 --- a/doc/91_relnotes.qbk +++ b/doc/91_relnotes.qbk @@ -13,7 +13,7 @@ [heading Boost Release 1.66] -* On newer compilers `optional` is now trivially-copyable for trivial `T`s. This uses a different storage (just `T` rather than `aligned_storage`). We require the compiler to support defaulted functions and type traits. Otherwise, we still use the the plain storage for scalar types. +* On newer compilers `optional` is now trivially-copyable for scalar `T`s. This uses a different storage (just `T` rather than `aligned_storage`). We require the compiler to support defaulted functions. [heading Boost Release 1.63] diff --git a/doc/html/boost_optional/relnotes.html b/doc/html/boost_optional/relnotes.html index 5ccc2d7..6cd8753 100644 --- a/doc/html/boost_optional/relnotes.html +++ b/doc/html/boost_optional/relnotes.html @@ -33,11 +33,10 @@
  • On newer compilers optional - is now trivially-copyable for trivial Ts. + is now trivially-copyable for scalar Ts. This uses a different storage (just T rather than aligned_storage). - We require the compiler to support defaulted functions and type traits. - Otherwise, we still use the the plain storage for scalar types. + We require the compiler to support defaulted functions.

diff --git a/doc/html/boost_optional/tutorial/performance_considerations.html b/doc/html/boost_optional/tutorial/performance_considerations.html index 40b4713..f54e49e 100644 --- a/doc/html/boost_optional/tutorial/performance_considerations.html +++ b/doc/html/boost_optional/tutorial/performance_considerations.html @@ -43,7 +43,7 @@ Lifetime of the T inside _storage is manually controlled with placement-news and pseudo-destructor - calls. However, for trivial Ts + calls. However, for scalar Ts we use a different way of storage, by simply holding a T:

template <typename T>
@@ -55,15 +55,13 @@
 

We call it a direct storage. This makes optional<T> a - trivially-copyable type for trivial Ts. - This only works for compilers that support defaulted functions and type traits. - On compilers without defaulted functions we still use the direct storage, - but optional<T> is - no longer recognized as trivially-copyable. On compilers that do not fully - support type traits, we still use the direct storage for scalar types, but - we leave the programmer a way of customizing her type, so that it is reconized - by optional as trivial, by - specializing type trait boost::opitonal_config::is_type_trivial: + trivially-copyable type for scalar Ts. + This only works for compilers that support defaulted functions. On compilers + without defaulted functions we still use the direct storage, but optional<T> is + no longer recognized as trivially-copyable. Apart from scalar types, we leave + the programmer a way of customizing her type, so that it is reconized by + optional as candidate for + optimized storage, by specializing type trait boost::opitonal_config::optional_uses_direct_storage_for:

struct X // not trivial
 {
@@ -72,7 +70,7 @@
 
 namespace boost { namespace optional_config {
 
-  template <> struct is_type_trivial<X> : boost::true_type {};
+  template <> struct optional_uses_direct_storage_for<X> : boost::true_type {};
 
 }}
 
diff --git a/doc/html/index.html b/doc/html/index.html index 04c4c88..cad53fb 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -146,7 +146,7 @@ - +

Last revised: October 30, 2017 at 22:34:46 GMT

Last revised: November 04, 2017 at 16:36:14 GMT


diff --git a/include/boost/optional/detail/experimental_traits.hpp b/include/boost/optional/detail/experimental_traits.hpp new file mode 100644 index 0000000..6eded58 --- /dev/null +++ b/include/boost/optional/detail/experimental_traits.hpp @@ -0,0 +1,98 @@ +// Copyright (C) 2017 Andrzej Krzemienski. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/optional for documentation. +// +// You are welcome to contact the author at: +// akrzemi1@gmail.com + +#ifndef BOOST_OPTIONAL_DETAIL_EXPERIMENTAL_TRAITS_04NOV2017_HPP +#define BOOST_OPTIONAL_DETAIL_EXPERIMENTAL_TRAITS_04NOV2017_HPP + +#include +#include +#include + +namespace boost { namespace optional_detail { + +// The condition to use POD implementation + +#ifdef BOOST_OPTIONAL_CONFIG_NO_POD_SPEC +# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES +#elif defined BOOST_OPTIONAL_CONFIG_NO_SPEC_FOR_TRIVIAL_TYPES +# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES +#elif !defined BOOST_HAS_TRIVIAL_CONSTRUCTOR +# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES +#elif !defined BOOST_HAS_TRIVIAL_MOVE_ASSIGN +# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES +#elif !defined BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR +# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES +#elif !defined BOOST_HAS_TRIVIAL_COPY +# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES +#elif !defined BOOST_HAS_TRIVIAL_ASSIGN +# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES +#elif !defined BOOST_HAS_TRIVIAL_DESTRUCTOR +# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES +#elif BOOST_WORKAROUND(BOOST_GCC, < 50000) +# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES +#endif + +#if __cplusplus >= 201103L +# if BOOST_WORKAROUND(BOOST_GCC, >= 50000) +# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS +# elif (defined BOOST_CLANG) +# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS +# endif +#endif + + +#ifndef BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS +# define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) +#else +# define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) std::is_trivially_default_constructible::value +#endif + + + +#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES +template +struct is_type_trivially_copyable + : boost::conditional<(boost::has_trivial_copy_constructor::value && + boost::has_trivial_move_constructor::value && + boost::has_trivial_destructor::value && + boost::has_trivial_move_assign::value && + boost::has_trivial_assign::value), + boost::true_type, boost::false_type>::type +{}; +#else +template +struct is_type_trivially_copyable +: boost::conditional<(boost::is_scalar::value && !boost::is_const::value && !boost::is_volatile::value), + boost::true_type, boost::false_type>::type +{}; +#endif + + + +#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES +template +struct optional_uses_direct_storage_for_ + : boost::conditional< (is_type_trivially_copyable::value && BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T)) || + (boost::is_scalar::value && !boost::is_const::value && !boost::is_volatile::value) + , boost::true_type, boost::false_type>::type +{}; +#else +template +struct optional_uses_direct_storage_for_ + : boost::conditional<(boost::is_scalar::value && !boost::is_const::value && !boost::is_volatile::value) + , boost::true_type, boost::false_type>::type +{}; +#endif + + +}} // boost::optional_detail + +#endif diff --git a/include/boost/optional/detail/optional_config.hpp b/include/boost/optional/detail/optional_config.hpp index 3bf0cc2..02dac68 100644 --- a/include/boost/optional/detail/optional_config.hpp +++ b/include/boost/optional/detail/optional_config.hpp @@ -15,7 +15,6 @@ #include #include -#include #if (defined BOOST_NO_CXX11_RVALUE_REFERENCES) || (defined BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES) # define BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES @@ -126,38 +125,8 @@ #endif -// The condition to use POD implementation - -#ifdef BOOST_OPTIONAL_CONFIG_NO_POD_SPEC -# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES -#elif defined BOOST_OPTIONAL_CONFIG_NO_SPEC_FOR_TRIVIAL_TYPES -# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES -#elif !defined BOOST_HAS_TRIVIAL_CONSTRUCTOR -# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES -#elif !defined BOOST_HAS_TRIVIAL_MOVE_ASSIGN -# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES -#elif !defined BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR -# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES -#elif !defined BOOST_HAS_TRIVIAL_COPY -# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES -#elif !defined BOOST_HAS_TRIVIAL_ASSIGN -# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES -#elif !defined BOOST_HAS_TRIVIAL_DESTRUCTOR -# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES -#elif BOOST_WORKAROUND(BOOST_GCC, < 50000) -# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES -#endif - -#if __cplusplus >= 201103L -# if BOOST_WORKAROUND(BOOST_GCC, >= 50000) -# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS -# elif (defined BOOST_CLANG) -# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS -# endif -#endif - -#ifdef BOOST_OPTIONAL_CONFIG_NO_POD_SPEC -# define BOOST_OPTIONAL_DETAIL_NO_POD_SPEC +#ifdef BOOST_OPTIONAL_CONFIG_NO_DIRECT_STORAE_SPEC +# define BOOST_OPTIONAL_DETAIL_NO_DIRECT_STORAE_SPEC #endif diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index e7eab01..f2e24fc 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -40,12 +40,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include #include #include @@ -809,55 +803,21 @@ struct is_optional_val_init_candidate , boost::true_type, boost::false_type>::type {}; - -#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES -template -struct is_type_trivially_copyable - : boost::conditional<(boost::has_trivial_copy_constructor::value && - boost::has_trivial_move_constructor::value && - boost::has_trivial_destructor::value && - boost::has_trivial_move_assign::value && - boost::has_trivial_assign::value), - boost::true_type, boost::false_type>::type -{}; -#else -template -struct is_type_trivially_copyable -: boost::conditional<(boost::is_scalar::value && !boost::is_const::value && !boost::is_volatile::value), - boost::true_type, boost::false_type>::type -{}; -#endif - } // namespace optional_detail namespace optional_config { -#ifndef BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS -# define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) -#else -# define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) std::is_trivially_default_constructible::value -#endif - -#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES template -struct is_type_trivial - : boost::conditional< (optional_detail::is_type_trivially_copyable::value && BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T)) || - (boost::is_scalar::value && !boost::is_const::value && !boost::is_volatile::value) - , boost::true_type, boost::false_type>::type -{}; -#else -template -struct is_type_trivial +struct optional_uses_direct_storage_for : boost::conditional<(boost::is_scalar::value && !boost::is_const::value && !boost::is_volatile::value) , boost::true_type, boost::false_type>::type {}; -#endif } // namespace optional_config -#ifndef BOOST_OPTIONAL_DETAIL_NO_POD_SPEC -# define BOOST_OPTIONAL_BASE_TYPE(T) boost::conditional< optional_config::is_type_trivial::value, \ +#ifndef BOOST_OPTIONAL_DETAIL_NO_DIRECT_STORAE_SPEC +# define BOOST_OPTIONAL_BASE_TYPE(T) boost::conditional< optional_config::optional_uses_direct_storage_for::value, \ optional_detail::tc_optional_base, \ optional_detail::optional_base \ >::type diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 3098380..129dd49 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -76,6 +76,5 @@ import testing ; [ run-fail optional_xconfig_NO_PROPER_CONVERT_FROM_CONST_INT_fail.cpp ] [ run optional_xconfig_NO_LEGAL_CONVERT_FROM_REF_pass.cpp ] [ compile-fail optional_xconfig_NO_LEGAL_CONVERT_FROM_REF_fail.cpp ] - ; } diff --git a/test/optional_test_experimental_traits.cpp b/test/optional_test_experimental_traits.cpp new file mode 100644 index 0000000..14ab705 --- /dev/null +++ b/test/optional_test_experimental_traits.cpp @@ -0,0 +1,152 @@ +// Copyright (C) 2017 Andrzej Krzemienski. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/lib/optional for documentation. +// +// You are welcome to contact the author at: +// akrzemi1@gmail.com + +#include "boost/optional/optional.hpp" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#include "boost/core/lightweight_test.hpp" +#include "boost/core/lightweight_test_trait.hpp" +#include "boost/type_traits/is_base_of.hpp" +#include "boost/optional/detail/experimental_traits.hpp" + +#ifndef BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_FUNCTIONS + +struct PrivDefault +{ + private: PrivDefault() {} +}; + +struct CustDefault +{ + CustDefault() {} +}; + +struct CustomizedTrivial +{ + CustomizedTrivial() {} +}; + +struct DeletedDefault +{ + BOOST_DELETED_FUNCTION(DeletedDefault()) +}; + +namespace boost { namespace optional_config { + +template <> struct optional_uses_direct_storage_for : boost::true_type {}; + +}} + +struct CustDtor +{ + ~CustDtor() {} +}; + +struct NoDefault +{ + explicit NoDefault(int) {} +}; + +struct Empty {}; + +template +struct Aggregate { T t; U u; }; + +struct CustAssign +{ + CustAssign& operator=(CustAssign const&) { return *this; } +}; + +struct CustMove +{ + CustMove(CustMove &&) {} +}; + +void test_type_traits() +{ + // this only tests if type traits are implemented correctly + BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for )); + + BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for )); + + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for > )); + + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for > )); + + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); + + +#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES + BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for > )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for, double> > )); + + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable, double> > )); + + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); +#endif + + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for > )); + + BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable > )); +} + +void test_trivial_copyability() +{ + BOOST_TEST_TRAIT_TRUE((boost::is_base_of, boost::optional > )); + BOOST_TEST_TRAIT_TRUE((boost::is_base_of, boost::optional > )); + BOOST_TEST_TRAIT_TRUE((boost::is_base_of, boost::optional > )); + BOOST_TEST_TRAIT_FALSE((boost::is_base_of, boost::optional > )); + +#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > > )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable, double> > > )); + + BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable > )); +#endif +} + +#endif + +int main() +{ +#ifndef BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_FUNCTIONS + test_type_traits(); + test_trivial_copyability(); +#endif + return boost::report_errors(); +} diff --git a/test/optional_test_static_properties.cpp b/test/optional_test_static_properties.cpp index 5c7ad5b..2419221 100644 --- a/test/optional_test_static_properties.cpp +++ b/test/optional_test_static_properties.cpp @@ -18,6 +18,7 @@ #include "boost/core/lightweight_test.hpp" #include "boost/core/lightweight_test_trait.hpp" #include "boost/type_traits/is_base_of.hpp" +#include "boost/optional/detail/experimental_traits.hpp" #ifndef BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_FUNCTIONS @@ -43,7 +44,7 @@ struct DeletedDefault namespace boost { namespace optional_config { -template <> struct is_type_trivial : boost::true_type {}; +template <> struct optional_uses_direct_storage_for : boost::true_type {}; }} @@ -75,44 +76,37 @@ struct CustMove void test_type_traits() { // this only tests if type traits are implemented correctly - BOOST_TEST_TRAIT_TRUE(( boost::optional_config::is_type_trivial )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_config::is_type_trivial )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_config::is_type_trivial )); + BOOST_TEST_TRAIT_TRUE(( boost::optional_config::optional_uses_direct_storage_for )); - BOOST_TEST_TRAIT_FALSE(( boost::optional_config::is_type_trivial )); - BOOST_TEST_TRAIT_FALSE(( boost::optional_config::is_type_trivial )); - BOOST_TEST_TRAIT_FALSE(( boost::optional_config::is_type_trivial )); - BOOST_TEST_TRAIT_FALSE(( boost::optional_config::is_type_trivial > )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for > )); - BOOST_TEST_TRAIT_FALSE(( boost::optional_config::is_type_trivial )); - BOOST_TEST_TRAIT_FALSE(( boost::optional_config::is_type_trivial )); - BOOST_TEST_TRAIT_FALSE(( boost::optional_config::is_type_trivial )); - BOOST_TEST_TRAIT_FALSE(( boost::optional_config::is_type_trivial > )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for > )); BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); - + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for > )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for, double> > )); #ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES - BOOST_TEST_TRAIT_TRUE(( boost::optional_config::is_type_trivial )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_config::is_type_trivial > )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_config::is_type_trivial, double> > )); BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable, double> > )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); #endif - BOOST_TEST_TRAIT_FALSE(( boost::optional_config::is_type_trivial )); - BOOST_TEST_TRAIT_FALSE(( boost::optional_config::is_type_trivial > )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_config::optional_uses_direct_storage_for > )); BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable )); BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable )); @@ -131,12 +125,13 @@ void test_trivial_copyability() BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable > > )); - BOOST_TEST_TRAIT_TRUE(( boost::optional_detail::is_type_trivially_copyable, double> > > )); BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable > )); #endif + + BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable > )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable > > )); + BOOST_TEST_TRAIT_FALSE(( boost::optional_detail::is_type_trivially_copyable, double> > > )); } #endif