From a6e879f0914e98db2c5d94fff2a33ce0539a06ab Mon Sep 17 00:00:00 2001 From: John Maddock Date: Thu, 25 Jan 2018 13:18:38 +0000 Subject: [PATCH] Add tests and tentative fix for issue with clang mis-identifying pairs of non-constructible types. See github #51. --- include/boost/type_traits/is_default_constructible.hpp | 6 ++++++ test/has_trivial_constr_test.cpp | 1 + test/is_default_constr_test.cpp | 2 ++ 3 files changed, 9 insertions(+) diff --git a/include/boost/type_traits/is_default_constructible.hpp b/include/boost/type_traits/is_default_constructible.hpp index fa5d76a..99c911f 100644 --- a/include/boost/type_traits/is_default_constructible.hpp +++ b/include/boost/type_traits/is_default_constructible.hpp @@ -16,6 +16,9 @@ #if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40700) #include #endif +#ifdef __clang__ +#include // std::pair +#endif #if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800) && !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40500) @@ -55,6 +58,9 @@ namespace boost{ template struct is_default_constructible : public is_default_constructible{}; template struct is_default_constructible : public is_default_constructible{}; template struct is_default_constructible : public integral_constant{}; +#ifdef __clang__ + template struct is_default_constructible > : public integral_constant::value && is_default_constructible::value>{}; +#endif #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template struct is_default_constructible : public integral_constant{}; #endif diff --git a/test/has_trivial_constr_test.cpp b/test/has_trivial_constr_test.cpp index 9328b51..455ee95 100644 --- a/test/has_trivial_constr_test.cpp +++ b/test/has_trivial_constr_test.cpp @@ -207,6 +207,7 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_constructor::v BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_constructor::value, false); #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_constructor::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::has_trivial_constructor >::value), false); #endif TT_TEST_END diff --git a/test/is_default_constr_test.cpp b/test/is_default_constr_test.cpp index 9992d4a..ba54e32 100644 --- a/test/is_default_constr_test.cpp +++ b/test/is_default_constr_test.cpp @@ -197,9 +197,11 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible::value, BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible::value, false); #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_default_constructible >::value), false); #endif #if !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800) BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_default_constructible >::value), false); #endif TT_TEST_END