2 // traits/static_require.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_TRAITS_STATIC_REQUIRE_HPP
12 #define BOOST_ASIO_TRAITS_STATIC_REQUIRE_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/detail/type_traits.hpp>
20 #include <boost/asio/traits/static_query.hpp>
22 #if defined(BOOST_ASIO_HAS_DECLTYPE) \
23 && defined(BOOST_ASIO_HAS_NOEXCEPT)
24 # define BOOST_ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT 1
25 #endif // defined(BOOST_ASIO_HAS_DECLTYPE)
26 // && defined(BOOST_ASIO_HAS_NOEXCEPT)
28 #include <boost/asio/detail/push_options.hpp>
34 template <typename T, typename Property, typename = void>
35 struct static_require_default;
37 template <typename T, typename Property, typename = void>
38 struct static_require;
43 struct no_static_require
45 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = false);
48 template <typename T, typename Property, typename = void>
49 struct static_require_trait :
51 is_same<T, typename decay<T>::type>::value
52 && is_same<Property, typename decay<Property>::type>::value,
54 traits::static_require<
55 typename decay<T>::type,
56 typename decay<Property>::type>
61 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT)
63 #if defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
65 template <typename T, typename Property>
66 struct static_require_trait<T, Property,
68 decay<Property>::type::value() == traits::static_query<T, Property>::value()
71 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
74 #else // defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
76 false_type static_require_test(...);
78 template <typename T, typename Property>
79 true_type static_require_test(T*, Property*,
81 Property::value() == traits::static_query<T, Property>::value()
84 template <typename T, typename Property>
85 struct has_static_require
87 BOOST_ASIO_STATIC_CONSTEXPR(bool, value =
88 decltype((static_require_test)(
89 static_cast<T*>(0), static_cast<Property*>(0)))::value);
92 template <typename T, typename Property>
93 struct static_require_trait<T, Property,
95 has_static_require<typename decay<T>::type,
96 typename decay<Property>::type>::value
99 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
102 #endif // defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
104 #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT)
106 } // namespace detail
109 template <typename T, typename Property, typename>
110 struct static_require_default : detail::static_require_trait<T, Property>
114 template <typename T, typename Property, typename>
115 struct static_require : static_require_default<T, Property>
119 } // namespace traits
123 #include <boost/asio/detail/pop_options.hpp>
125 #endif // BOOST_ASIO_TRAITS_STATIC_REQUIRE_HPP