]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | // (C) Copyright John Maddock 2015. | |
3 | // Use, modification and distribution are subject to the Boost Software License, | |
4 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
5 | // http://www.boost.org/LICENSE_1_0.txt). | |
6 | // | |
7 | // See http://www.boost.org/libs/type_traits for most recent version including documentation. | |
8 | ||
9 | #ifndef BOOST_TT_IS_DEFAULT_CONSTRUCTIBLE_HPP_INCLUDED | |
10 | #define BOOST_TT_IS_DEFAULT_CONSTRUCTIBLE_HPP_INCLUDED | |
11 | ||
12 | #include <cstddef> // size_t | |
13 | #include <boost/type_traits/integral_constant.hpp> | |
14 | #include <boost/detail/workaround.hpp> | |
15 | ||
16 | #if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40700) | |
17 | #include <boost/type_traits/is_abstract.hpp> | |
18 | #endif | |
19 | ||
20 | #if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800) && !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40500) | |
21 | ||
22 | #include <boost/type_traits/detail/yes_no_type.hpp> | |
23 | ||
24 | namespace boost{ | |
25 | ||
26 | namespace detail{ | |
27 | ||
28 | struct is_default_constructible_imp | |
29 | { | |
30 | template<typename _Tp, typename = decltype(_Tp())> | |
31 | static boost::type_traits::yes_type test(int); | |
32 | ||
33 | template<typename> | |
34 | static boost::type_traits::no_type test(...); | |
35 | }; | |
36 | #if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40700) | |
37 | template<class T, bool b> | |
38 | struct is_default_constructible_abstract_filter | |
39 | { | |
40 | static const bool value = sizeof(is_default_constructible_imp::test<T>(0)) == sizeof(boost::type_traits::yes_type); | |
41 | }; | |
42 | template<class T> | |
43 | struct is_default_constructible_abstract_filter<T, true> | |
44 | { | |
45 | static const bool value = false; | |
46 | }; | |
47 | #endif | |
48 | } | |
49 | ||
50 | #if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40700) | |
51 | template <class T> struct is_default_constructible : public integral_constant<bool, detail::is_default_constructible_abstract_filter<T, boost::is_abstract<T>::value>::value>{}; | |
52 | #else | |
53 | template <class T> struct is_default_constructible : public integral_constant<bool, sizeof(detail::is_default_constructible_imp::test<T>(0)) == sizeof(boost::type_traits::yes_type)>{}; | |
54 | #endif | |
55 | template <class T, std::size_t N> struct is_default_constructible<T[N]> : public is_default_constructible<T>{}; | |
56 | template <class T> struct is_default_constructible<T[]> : public is_default_constructible<T>{}; | |
57 | template <class T> struct is_default_constructible<T&> : public integral_constant<bool, false>{}; | |
58 | #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) | |
59 | template <class T> struct is_default_constructible<T&&> : public integral_constant<bool, false>{}; | |
60 | #endif | |
61 | template <> struct is_default_constructible<void> : public integral_constant<bool, false>{}; | |
62 | template <> struct is_default_constructible<void const> : public integral_constant<bool, false>{}; | |
63 | template <> struct is_default_constructible<void volatile> : public integral_constant<bool, false>{}; | |
64 | template <> struct is_default_constructible<void const volatile> : public integral_constant<bool, false>{}; | |
65 | ||
66 | #else | |
67 | ||
68 | #include <boost/type_traits/is_pod.hpp> | |
69 | ||
70 | namespace boost{ | |
71 | ||
72 | // We don't know how to implement this, note we can not use has_trivial_constructor here | |
73 | // because the correct implementation of that trait requires this one: | |
74 | template <class T> struct is_default_constructible : public is_pod<T>{}; | |
75 | template <> struct is_default_constructible<void> : public integral_constant<bool, false>{}; | |
76 | template <> struct is_default_constructible<void const> : public integral_constant<bool, false>{}; | |
77 | template <> struct is_default_constructible<void volatile> : public integral_constant<bool, false>{}; | |
78 | template <> struct is_default_constructible<void const volatile> : public integral_constant<bool, false>{}; | |
79 | ||
80 | #endif | |
81 | ||
82 | } // namespace boost | |
83 | ||
84 | #endif // BOOST_TT_IS_DEFAULT_CONSTRUCTIBLE_HPP_INCLUDED |