]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | |
2 | // (C) Copyright John Maddock 2017. | |
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_COMPLETE_HPP_INCLUDED | |
10 | #define BOOST_TT_IS_COMPLETE_HPP_INCLUDED | |
11 | ||
92f5a8d4 | 12 | #include <boost/type_traits/declval.hpp> |
11fdf7f2 TL |
13 | #include <boost/type_traits/integral_constant.hpp> |
14 | #include <boost/type_traits/remove_reference.hpp> | |
15 | #include <boost/type_traits/is_function.hpp> | |
92f5a8d4 | 16 | #include <boost/type_traits/detail/yes_no_type.hpp> |
11fdf7f2 | 17 | #include <boost/config/workaround.hpp> |
1e59de90 | 18 | #include <cstddef> |
11fdf7f2 TL |
19 | |
20 | /* | |
21 | * CAUTION: | |
22 | * ~~~~~~~~ | |
23 | * | |
24 | * THIS TRAIT EXISTS SOLELY TO GENERATE HARD ERRORS WHEN A ANOTHER TRAIT | |
25 | * WHICH REQUIRES COMPLETE TYPES AS ARGUMENTS IS PASSED AN INCOMPLETE TYPE | |
26 | * | |
27 | * DO NOT MAKE GENERAL USE OF THIS TRAIT, AS THE COMPLETENESS OF A TYPE | |
28 | * VARIES ACROSS TRANSLATION UNITS AS WELL AS WITHIN A SINGLE UNIT. | |
29 | * | |
30 | */ | |
31 | ||
32 | namespace boost { | |
33 | ||
34 | ||
35 | // | |
36 | // We will undef this if the trait isn't fully functional: | |
37 | // | |
38 | #define BOOST_TT_HAS_WORKING_IS_COMPLETE | |
39 | ||
40 | #if !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_MSVC, <= 1900) && !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40600) | |
41 | ||
42 | namespace detail{ | |
43 | ||
1e59de90 | 44 | template <std::size_t N> |
11fdf7f2 TL |
45 | struct ok_tag { double d; char c[N]; }; |
46 | ||
47 | template <class T> | |
48 | ok_tag<sizeof(T)> check_is_complete(int); | |
49 | template <class T> | |
50 | char check_is_complete(...); | |
51 | } | |
52 | ||
53 | template <class T> struct is_complete | |
92f5a8d4 | 54 | : public integral_constant<bool, ::boost::is_function<typename boost::remove_reference<T>::type>::value || (sizeof(boost::detail::check_is_complete<T>(0)) != sizeof(char))> {}; |
11fdf7f2 TL |
55 | |
56 | #elif !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) && !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40500) | |
57 | ||
58 | namespace detail | |
59 | { | |
60 | ||
61 | template <class T> | |
62 | struct is_complete_imp | |
63 | { | |
92f5a8d4 | 64 | template <class U, class = decltype(sizeof(boost::declval< U >())) > |
11fdf7f2 TL |
65 | static type_traits::yes_type check(U*); |
66 | ||
67 | template <class U> | |
68 | static type_traits::no_type check(...); | |
69 | ||
70 | static const bool value = sizeof(check<T>(0)) == sizeof(type_traits::yes_type); | |
71 | }; | |
72 | ||
73 | } // namespace detail | |
74 | ||
75 | ||
76 | template <class T> | |
77 | struct is_complete : boost::integral_constant<bool, ::boost::is_function<typename boost::remove_reference<T>::type>::value || ::boost::detail::is_complete_imp<T>::value> | |
78 | {}; | |
79 | template <class T> | |
80 | struct is_complete<T&> : boost::is_complete<T> {}; | |
81 | ||
82 | #else | |
83 | ||
84 | template <class T> struct is_complete | |
85 | : public boost::integral_constant<bool, true> {}; | |
86 | ||
87 | #undef BOOST_TT_HAS_WORKING_IS_COMPLETE | |
88 | ||
89 | #endif | |
90 | ||
91 | } // namespace boost | |
92 | ||
93 | #endif // BOOST_TT_IS_COMPLETE_HPP_INCLUDED |