1 //
2 // traits/query_static_constexpr_member.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_TRAITS_QUERY_STATIC_CONSTEXPR_MEMBER_HPP
12 #define BOOST_ASIO_TRAITS_QUERY_STATIC_CONSTEXPR_MEMBER_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 #include <boost/asio/detail/type_traits.hpp>
20 
21 #if defined(BOOST_ASIO_HAS_DECLTYPE) \
22   && defined(BOOST_ASIO_HAS_NOEXCEPT) \
23   && defined(BOOST_ASIO_HAS_CONSTEXPR) \
24   && defined(BOOST_ASIO_HAS_CONSTANT_EXPRESSION_SFINAE) \
25   && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
26 # define BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_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_CONSTANT_EXPRESSION_SFINAE)
31        //   && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
32 
33 #include <boost/asio/detail/push_options.hpp>
34 
35 namespace boost {
36 namespace asio {
37 namespace traits {
38 
39 template <typename T, typename Property, typename = void>
40 struct query_static_constexpr_member_default;
41 
42 template <typename T, typename Property, typename = void>
43 struct query_static_constexpr_member;
44 
45 } // namespace traits
46 namespace detail {
47 
48 struct no_query_static_constexpr_member
49 {
50   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = false);
51 };
52 
53 template <typename T, typename Property, typename = void>
54 struct query_static_constexpr_member_trait :
55   conditional<
56     is_same<T, typename decay<T>::type>::value
57       && is_same<Property, typename decay<Property>::type>::value,
58     no_query_static_constexpr_member,
59     traits::query_static_constexpr_member<
60       typename decay<T>::type,
61       typename decay<Property>::type>
62   >::type
63 {
64 };
65 
66 #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
67 
68 template <typename T, typename Property>
69 struct query_static_constexpr_member_trait<T, Property,
70   typename enable_if<
71     (static_cast<void>(T::query(Property{})), true)
72   >::type>
73 {
74   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
75 
76   using result_type = decltype(T::query(Property{}));
77 
78   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
79     noexcept(T::query(Property{})));
80 
valueboost::asio::detail::query_static_constexpr_member_trait81   static BOOST_ASIO_CONSTEXPR result_type value() noexcept(is_noexcept)
82   {
83     return T::query(Property{});
84   }
85 };
86 
87 #endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
88 
89 } // namespace detail
90 namespace traits {
91 
92 template <typename T, typename Property, typename>
93 struct query_static_constexpr_member_default :
94   detail::query_static_constexpr_member_trait<T, Property>
95 {
96 };
97 
98 template <typename T, typename Property, typename>
99 struct query_static_constexpr_member :
100   query_static_constexpr_member_default<T, Property>
101 {
102 };
103 
104 } // namespace traits
105 } // namespace asio
106 } // namespace boost
107 
108 #include <boost/asio/detail/pop_options.hpp>
109 
110 #endif // BOOST_ASIO_TRAITS_QUERY_STATIC_CONSTEXPR_MEMBER_HPP
111