• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // detail/type_traits.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef BOOST_ASIO_DETAIL_TYPE_TRAITS_HPP
12 #define BOOST_ASIO_DETAIL_TYPE_TRAITS_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include <boost/asio/detail/config.hpp>
19 
20 #if defined(BOOST_ASIO_HAS_STD_TYPE_TRAITS)
21 # include <type_traits>
22 #else // defined(BOOST_ASIO_HAS_STD_TYPE_TRAITS)
23 # include <boost/type_traits/add_const.hpp>
24 # include <boost/type_traits/add_lvalue_reference.hpp>
25 # include <boost/type_traits/aligned_storage.hpp>
26 # include <boost/type_traits/alignment_of.hpp>
27 # include <boost/type_traits/conditional.hpp>
28 # include <boost/type_traits/decay.hpp>
29 # include <boost/type_traits/has_nothrow_copy.hpp>
30 # include <boost/type_traits/has_nothrow_destructor.hpp>
31 # include <boost/type_traits/integral_constant.hpp>
32 # include <boost/type_traits/is_base_of.hpp>
33 # include <boost/type_traits/is_class.hpp>
34 # include <boost/type_traits/is_const.hpp>
35 # include <boost/type_traits/is_convertible.hpp>
36 # include <boost/type_traits/is_constructible.hpp>
37 # include <boost/type_traits/is_copy_constructible.hpp>
38 # include <boost/type_traits/is_destructible.hpp>
39 # include <boost/type_traits/is_function.hpp>
40 # include <boost/type_traits/is_object.hpp>
41 # include <boost/type_traits/is_same.hpp>
42 # include <boost/type_traits/remove_cv.hpp>
43 # include <boost/type_traits/remove_pointer.hpp>
44 # include <boost/type_traits/remove_reference.hpp>
45 # include <boost/utility/declval.hpp>
46 # include <boost/utility/enable_if.hpp>
47 # include <boost/utility/result_of.hpp>
48 #endif // defined(BOOST_ASIO_HAS_STD_TYPE_TRAITS)
49 
50 namespace boost {
51 namespace asio {
52 
53 #if defined(BOOST_ASIO_HAS_STD_TYPE_TRAITS)
54 using std::add_const;
55 using std::add_lvalue_reference;
56 using std::aligned_storage;
57 using std::alignment_of;
58 using std::conditional;
59 using std::decay;
60 using std::declval;
61 using std::enable_if;
62 using std::false_type;
63 using std::integral_constant;
64 using std::is_base_of;
65 using std::is_class;
66 using std::is_const;
67 using std::is_constructible;
68 using std::is_convertible;
69 using std::is_copy_constructible;
70 using std::is_destructible;
71 using std::is_function;
72 using std::is_move_constructible;
73 using std::is_nothrow_copy_constructible;
74 using std::is_nothrow_destructible;
75 using std::is_object;
76 using std::is_reference;
77 using std::is_same;
78 using std::is_scalar;
79 using std::remove_cv;
80 template <typename T>
81 struct remove_cvref : remove_cv<typename std::remove_reference<T>::type> {};
82 using std::remove_pointer;
83 using std::remove_reference;
84 #if defined(BOOST_ASIO_HAS_STD_INVOKE_RESULT)
85 template <typename> struct result_of;
86 template <typename F, typename... Args>
87 struct result_of<F(Args...)> : std::invoke_result<F, Args...> {};
88 #else // defined(BOOST_ASIO_HAS_STD_INVOKE_RESULT)
89 using std::result_of;
90 #endif // defined(BOOST_ASIO_HAS_STD_INVOKE_RESULT)
91 using std::true_type;
92 #else // defined(BOOST_ASIO_HAS_STD_TYPE_TRAITS)
93 using boost::add_const;
94 using boost::add_lvalue_reference;
95 using boost::aligned_storage;
96 using boost::alignment_of;
97 template <bool Condition, typename Type = void>
98 struct enable_if : boost::enable_if_c<Condition, Type> {};
99 using boost::conditional;
100 using boost::decay;
101 using boost::declval;
102 using boost::false_type;
103 using boost::integral_constant;
104 using boost::is_base_of;
105 using boost::is_class;
106 using boost::is_const;
107 using boost::is_constructible;
108 using boost::is_convertible;
109 using boost::is_copy_constructible;
110 using boost::is_destructible;
111 using boost::is_function;
112 #if defined(BOOST_ASIO_HAS_MOVE)
113 template <typename T>
114 struct is_move_constructible : false_type {};
115 #else // defined(BOOST_ASIO_HAS_MOVE)
116 template <typename T>
117 struct is_move_constructible : is_copy_constructible<T> {};
118 #endif // defined(BOOST_ASIO_HAS_MOVE)
119 template <typename T>
120 struct is_nothrow_copy_constructible : boost::has_nothrow_copy<T> {};
121 template <typename T>
122 struct is_nothrow_destructible : boost::has_nothrow_destructor<T> {};
123 using boost::is_object;
124 using boost::is_reference;
125 using boost::is_same;
126 using boost::is_scalar;
127 using boost::remove_cv;
128 template <typename T>
129 struct remove_cvref : remove_cv<typename boost::remove_reference<T>::type> {};
130 using boost::remove_pointer;
131 using boost::remove_reference;
132 using boost::result_of;
133 using boost::true_type;
134 #endif // defined(BOOST_ASIO_HAS_STD_TYPE_TRAITS)
135 
136 template <typename> struct void_type { typedef void type; };
137 
138 #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
139 
140 template <typename...> struct conjunction : true_type {};
141 template <typename T> struct conjunction<T> : T {};
142 template <typename Head, typename... Tail> struct conjunction<Head, Tail...> :
143   conditional<Head::value, conjunction<Tail...>, Head>::type {};
144 
145 #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
146 
147 struct defaulted_constraint
148 {
defaulted_constraintboost::asio::defaulted_constraint149   BOOST_ASIO_CONSTEXPR defaulted_constraint() {}
150 };
151 
152 template <bool Condition, typename Type = int>
153 struct constraint : enable_if<Condition, Type> {};
154 
155 } // namespace asio
156 } // namespace boost
157 
158 #endif // BOOST_ASIO_DETAIL_TYPE_TRAITS_HPP
159