diff --git a/include/boost/type_traits/is_constructible.hpp b/include/boost/type_traits/is_constructible.hpp index 0361012..d1accc1 100644 --- a/include/boost/type_traits/is_constructible.hpp +++ b/include/boost/type_traits/is_constructible.hpp @@ -14,6 +14,7 @@ #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800) +#include #include #include @@ -25,14 +26,26 @@ namespace boost{ { template()...))> static boost::type_traits::yes_type test(int); - - template + template static boost::type_traits::no_type test(...); + + template()))> + static boost::type_traits::yes_type test1(int); + template + static boost::type_traits::no_type test1(...); + + template + static boost::type_traits::yes_type ref_test(T); + template + static boost::type_traits::no_type ref_test(...); }; } template struct is_constructible : public integral_constant(0)) == sizeof(boost::type_traits::yes_type)>{}; + template struct is_constructible : public integral_constant::value && sizeof(detail::is_constructible_imp::test1(0)) == sizeof(boost::type_traits::yes_type)>{}; + template struct is_constructible : public integral_constant(detail::tt_declval())) == sizeof(boost::type_traits::yes_type)>{}; + template struct is_constructible : public integral_constant(detail::tt_declval())) == sizeof(boost::type_traits::yes_type)>{}; #else diff --git a/include/boost/type_traits/is_destructible.hpp b/include/boost/type_traits/is_destructible.hpp new file mode 100644 index 0000000..fe421d9 --- /dev/null +++ b/include/boost/type_traits/is_destructible.hpp @@ -0,0 +1,49 @@ + +// (C) Copyright John Maddock 2015. +// Use, modification and distribution are 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/type_traits for most recent version including documentation. + +#ifndef BOOST_TT_IS_DESTRUCTIBLE_HPP_INCLUDED +#define BOOST_TT_IS_DESTRUCTIBLE_HPP_INCLUDED + +#include +#include + +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800) + +#include +#include + +namespace boost{ + + namespace detail{ + + struct is_destructible_imp + { + template().~T())> + static boost::type_traits::yes_type test(int); + template + static boost::type_traits::no_type test(...); + }; + + } + + template struct is_destructible : public integral_constant(0)) == sizeof(boost::type_traits::yes_type)>{}; + +#else + +#include +#include + +namespace boost{ + + // We don't know how to implement this: + template struct is_destructible : public integral_constant::value || is_class::value>{}; +#endif + +} // namespace boost + +#endif // BOOST_TT_IS_DESTRUCTIBLE_HPP_INCLUDED diff --git a/test/is_constructible_test.cpp b/test/is_constructible_test.cpp new file mode 100644 index 0000000..8bcd7ab --- /dev/null +++ b/test/is_constructible_test.cpp @@ -0,0 +1,79 @@ + +// (C) Copyright John Maddock 2000. +// Use, modification and distribution are 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) + +#include "test.hpp" +#include "check_integral_constant.hpp" +#ifdef TEST_STD +# include +#else +# include +#endif + + +struct non_copy_constructible +{ + non_copy_constructible(); + non_copy_constructible(int); + non_copy_constructible(double*, double*); +#ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS + non_copy_constructible(const non_copy_constructible&) = delete; +#endif +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + non_copy_constructible(non_copy_constructible&&); +#endif +}; + + +struct A { }; +struct B : A { }; + +TT_TEST_BEGIN(is_constructible) + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value) , false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value) , false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value) , false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value) , false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value) , false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value) , false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value) , false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value) , false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value) , false); +#endif +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), false); + +BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible::value), true, false); +BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible::value), true, false); +BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible::value), true, false); +BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible::value), true, false); +BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible::value), true, false); +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800) +BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible::value), true, false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), false); +#endif +#ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), false); +#endif + +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), true); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), true); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), true); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), true); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), true); + +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), true); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), true); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible::value), false); + +TT_TEST_END +