File indexing completed on 2025-01-18 09:53:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_TT_IS_CONSTRUCTIBLE_HPP_INCLUDED
0010 #define BOOST_TT_IS_CONSTRUCTIBLE_HPP_INCLUDED
0011
0012 #include <boost/type_traits/integral_constant.hpp>
0013 #include <boost/detail/workaround.hpp>
0014
0015 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800) && !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40500)
0016
0017 #include <boost/type_traits/is_destructible.hpp>
0018 #include <boost/type_traits/is_default_constructible.hpp>
0019 #include <boost/type_traits/detail/yes_no_type.hpp>
0020 #include <boost/type_traits/declval.hpp>
0021 #include <boost/type_traits/is_complete.hpp>
0022 #include <boost/static_assert.hpp>
0023
0024 #define BOOST_TT_IS_CONSTRUCTIBLE_CONFORMING 1
0025
0026 namespace boost{
0027
0028 namespace detail{
0029
0030 struct is_constructible_imp
0031 {
0032 template<typename T, typename ...TheArgs, typename = decltype(T(boost::declval<TheArgs>()...))>
0033 static boost::type_traits::yes_type test(int);
0034 template<typename, typename...>
0035 static boost::type_traits::no_type test(...);
0036
0037 template<typename T, typename Arg, typename = decltype(::new T(boost::declval<Arg>()))>
0038 static boost::type_traits::yes_type test1(int);
0039 template<typename, typename>
0040 static boost::type_traits::no_type test1(...);
0041
0042 template <typename T>
0043 static boost::type_traits::yes_type ref_test(T);
0044 template <typename T>
0045 static boost::type_traits::no_type ref_test(...);
0046 };
0047
0048 }
0049
0050 template <class T, class ...Args> struct is_constructible : public integral_constant<bool, sizeof(detail::is_constructible_imp::test<T, Args...>(0)) == sizeof(boost::type_traits::yes_type)>
0051 {
0052 BOOST_STATIC_ASSERT_MSG(::boost::is_complete<T>::value, "The target type must be complete in order to test for constructibility");
0053 };
0054 template <class T, class Arg> struct is_constructible<T, Arg> : public integral_constant<bool, is_destructible<T>::value && sizeof(boost::detail::is_constructible_imp::test1<T, Arg>(0)) == sizeof(boost::type_traits::yes_type)>
0055 {
0056 BOOST_STATIC_ASSERT_MSG(::boost::is_complete<T>::value, "The target type must be complete in order to test for constructibility");
0057 };
0058 template <class Ref, class Arg> struct is_constructible<Ref&, Arg> : public integral_constant<bool, sizeof(detail::is_constructible_imp::ref_test<Ref&>(boost::declval<Arg>())) == sizeof(boost::type_traits::yes_type)>{};
0059 template <class Ref, class Arg> struct is_constructible<Ref&&, Arg> : public integral_constant<bool, sizeof(detail::is_constructible_imp::ref_test<Ref&&>(boost::declval<Arg>())) == sizeof(boost::type_traits::yes_type)>{};
0060
0061 template <> struct is_constructible<void> : public false_type{};
0062 template <> struct is_constructible<void const> : public false_type{};
0063 template <> struct is_constructible<void const volatile> : public false_type{};
0064 template <> struct is_constructible<void volatile> : public false_type{};
0065
0066 template <class T> struct is_constructible<T> : public is_default_constructible<T>{};
0067
0068 #else
0069
0070 #include <boost/type_traits/is_convertible.hpp>
0071 #include <boost/type_traits/is_default_constructible.hpp>
0072
0073 namespace boost{
0074
0075
0076 template <class T, class U = void> struct is_constructible : public is_convertible<U, T>{};
0077 template <class T> struct is_constructible<T, void> : public is_default_constructible<T>{};
0078 template <> struct is_constructible<void, void> : public false_type{};
0079 template <> struct is_constructible<void const, void> : public false_type{};
0080 template <> struct is_constructible<void const volatile, void> : public false_type{};
0081 template <> struct is_constructible<void volatile, void> : public false_type{};
0082 template <class Ref> struct is_constructible<Ref&, void> : public false_type{};
0083 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
0084 template <class Ref> struct is_constructible<Ref&&, void> : public false_type{};
0085 #endif
0086 #endif
0087
0088 }
0089
0090 #endif