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_DESTRUCTIBLE_HPP_INCLUDED |
10 | #define BOOST_TT_IS_DESTRUCTIBLE_HPP_INCLUDED |
11 | |
12 | #include <cstddef> // size_t |
13 | #include <boost/type_traits/integral_constant.hpp> |
14 | #include <boost/detail/workaround.hpp> |
15 | #include <boost/type_traits/is_complete.hpp> |
16 | #include <boost/static_assert.hpp> |
17 | |
18 | #if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800) |
19 | |
20 | #include <boost/type_traits/detail/yes_no_type.hpp> |
21 | #include <boost/type_traits/declval.hpp> |
22 | |
23 | namespace boost{ |
24 | |
25 | namespace detail{ |
26 | |
27 | struct is_destructible_imp |
28 | { |
29 | template<typename T, typename = decltype(boost::declval<T&>().~T())> |
30 | static boost::type_traits::yes_type test(int); |
31 | template<typename> |
32 | static boost::type_traits::no_type test(...); |
33 | }; |
34 | |
35 | } |
36 | |
37 | template <class T> struct is_destructible : public integral_constant<bool, sizeof(boost::detail::is_destructible_imp::test<T>(0)) == sizeof(boost::type_traits::yes_type)> |
38 | { |
39 | BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to is_destructible must be complete types"); |
40 | }; |
41 | |
42 | #else |
43 | |
44 | #include <boost/type_traits/is_pod.hpp> |
45 | #include <boost/type_traits/is_class.hpp> |
46 | |
47 | namespace boost{ |
48 | |
49 | // We don't know how to implement this: |
50 | template <class T> struct is_destructible : public integral_constant<bool, is_pod<T>::value || is_class<T>::value> |
51 | { |
52 | BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to is_destructible must be complete types"); |
53 | }; |
54 | #endif |
55 | |
56 | template <> struct is_destructible<void> : public false_type{}; |
57 | template <> struct is_destructible<void const> : public false_type{}; |
58 | template <> struct is_destructible<void volatile> : public false_type{}; |
59 | template <> struct is_destructible<void const volatile> : public false_type{}; |
60 | template <class T> struct is_destructible<T&> : public is_destructible<T>{}; |
61 | #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES |
62 | template <class T> struct is_destructible<T&&> : public is_destructible<T>{}; |
63 | #endif |
64 | template <class T, std::size_t N> struct is_destructible<T[N]> : public is_destructible<T>{}; |
65 | template <class T> struct is_destructible<T[]> : public is_destructible<T>{}; |
66 | |
67 | } // namespace boost |
68 | |
69 | #endif // BOOST_TT_IS_DESTRUCTIBLE_HPP_INCLUDED |
70 |