1 | // |
2 | // traits/query_static_constexpr_member.hpp |
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
4 | // |
5 | // Copyright (c) 2003-2024 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_CONSTANT_EXPRESSION_SFINAE) \ |
22 | && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE) |
23 | # define BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT 1 |
24 | #endif // defined(BOOST_ASIO_HAS_CONSTANT_EXPRESSION_SFINAE) |
25 | // && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE) |
26 | |
27 | #include <boost/asio/detail/push_options.hpp> |
28 | |
29 | namespace boost { |
30 | namespace asio { |
31 | namespace traits { |
32 | |
33 | template <typename T, typename Property, typename = void> |
34 | struct query_static_constexpr_member_default; |
35 | |
36 | template <typename T, typename Property, typename = void> |
37 | struct query_static_constexpr_member; |
38 | |
39 | } // namespace traits |
40 | namespace detail { |
41 | |
42 | struct no_query_static_constexpr_member |
43 | { |
44 | static constexpr bool is_valid = false; |
45 | }; |
46 | |
47 | template <typename T, typename Property, typename = void> |
48 | struct query_static_constexpr_member_trait : |
49 | conditional_t< |
50 | is_same<T, decay_t<T>>::value |
51 | && is_same<Property, decay_t<Property>>::value, |
52 | no_query_static_constexpr_member, |
53 | traits::query_static_constexpr_member< |
54 | decay_t<T>, |
55 | decay_t<Property>> |
56 | > |
57 | { |
58 | }; |
59 | |
60 | #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) |
61 | |
62 | template <typename T, typename Property> |
63 | struct query_static_constexpr_member_trait<T, Property, |
64 | enable_if_t< |
65 | (static_cast<void>(T::query(Property{})), true) |
66 | >> |
67 | { |
68 | static constexpr bool is_valid = true; |
69 | |
70 | using result_type = decltype(T::query(Property{})); |
71 | |
72 | static constexpr bool is_noexcept = noexcept(T::query(Property{})); |
73 | |
74 | static constexpr result_type value() noexcept(is_noexcept) |
75 | { |
76 | return T::query(Property{}); |
77 | } |
78 | }; |
79 | |
80 | #endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) |
81 | |
82 | } // namespace detail |
83 | namespace traits { |
84 | |
85 | template <typename T, typename Property, typename> |
86 | struct query_static_constexpr_member_default : |
87 | detail::query_static_constexpr_member_trait<T, Property> |
88 | { |
89 | }; |
90 | |
91 | template <typename T, typename Property, typename> |
92 | struct query_static_constexpr_member : |
93 | query_static_constexpr_member_default<T, Property> |
94 | { |
95 | }; |
96 | |
97 | } // namespace traits |
98 | } // namespace asio |
99 | } // namespace boost |
100 | |
101 | #include <boost/asio/detail/pop_options.hpp> |
102 | |
103 | #endif // BOOST_ASIO_TRAITS_QUERY_STATIC_CONSTEXPR_MEMBER_HPP |
104 | |