2 // traits/static_query.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_QUERY_HPP
12 #define BOOST_ASIO_TRAITS_STATIC_QUERY_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>
21 #if defined(BOOST_ASIO_HAS_DECLTYPE) \
22 && defined(BOOST_ASIO_HAS_NOEXCEPT) \
23 && defined(BOOST_ASIO_HAS_CONSTEXPR) \
24 && defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) \
25 && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
26 # define BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT 1
27 #endif // defined(BOOST_ASIO_HAS_DECLTYPE)
28 // && defined(BOOST_ASIO_HAS_NOEXCEPT)
29 // && defined(BOOST_ASIO_HAS_CONSTEXPR)
30 // && defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
31 // && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
33 #include <boost/asio/detail/push_options.hpp>
39 template <typename T, typename Property, typename = void>
40 struct static_query_default;
42 template <typename T, typename Property, typename = void>
48 struct no_static_query
50 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = false);
51 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
54 template <typename T, typename Property, typename = void>
55 struct static_query_trait :
57 is_same<T, typename decay<T>::type>::value
58 && is_same<Property, typename decay<Property>::type>::value,
61 typename decay<T>::type,
62 typename decay<Property>::type>
67 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
69 template <typename T, typename Property>
70 struct static_query_trait<T, Property,
72 decltype(decay<Property>::type::template static_query_v<T>)
75 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
77 using result_type = decltype(
78 decay<Property>::type::template static_query_v<T>);
80 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
81 noexcept(decay<Property>::type::template static_query_v<T>));
83 static BOOST_ASIO_CONSTEXPR result_type value() noexcept(is_noexcept)
85 return decay<Property>::type::template static_query_v<T>;
89 #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
94 template <typename T, typename Property, typename>
95 struct static_query_default : detail::static_query_trait<T, Property>
99 template <typename T, typename Property, typename>
100 struct static_query : static_query_default<T, Property>
104 } // namespace traits
108 #include <boost/asio/detail/pop_options.hpp>
110 #endif // BOOST_ASIO_TRAITS_STATIC_QUERY_HPP