Clementine
query_static_constexpr_member.hpp
1 //
2 // traits/query_static_constexpr_member.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 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 ASIO_TRAITS_QUERY_STATIC_CONSTEXPR_MEMBER_HPP
12 #define 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 "asio/detail/config.hpp"
19 #include "asio/detail/type_traits.hpp"
20 
21 #if defined(ASIO_HAS_DECLTYPE) \
22  && defined(ASIO_HAS_NOEXCEPT) \
23  && defined(ASIO_HAS_CONSTEXPR) \
24  && defined(ASIO_HAS_CONSTANT_EXPRESSION_SFINAE) \
25  && defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
26 # define ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT 1
27 #endif // defined(ASIO_HAS_DECLTYPE)
28  // && defined(ASIO_HAS_NOEXCEPT)
29  // && defined(ASIO_HAS_CONSTEXPR)
30  // && defined(ASIO_HAS_CONSTANT_EXPRESSION_SFINAE)
31  // && defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
32 
33 #include "asio/detail/push_options.hpp"
34 
35 namespace asio {
36 namespace traits {
37 
38 template <typename T, typename Property, typename = void>
40 
41 template <typename T, typename Property, typename = void>
43 
44 } // namespace traits
45 namespace detail {
46 
48 {
49  ASIO_STATIC_CONSTEXPR(bool, is_valid = false);
50 };
51 
52 template <typename T, typename Property, typename = void>
54  conditional<
55  is_same<T, typename decay<T>::type>::value
56  && is_same<Property, typename decay<Property>::type>::value,
57  no_query_static_constexpr_member,
58  traits::query_static_constexpr_member<
59  typename decay<T>::type,
60  typename decay<Property>::type>
61  >::type
62 {
63 };
64 
65 #if defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
66 
67 template <typename T, typename Property>
68 struct query_static_constexpr_member_trait<T, Property,
69  typename enable_if<
70  (static_cast<void>(T::query(Property{})), true)
71  >::type>
72 {
73  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
74 
75  using result_type = decltype(T::query(Property{}));
76 
77  ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
78  noexcept(T::query(Property{})));
79 
80  static ASIO_CONSTEXPR result_type value() noexcept(is_noexcept)
81  {
82  return T::query(Property{});
83  }
84 };
85 
86 #endif // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
87 
88 } // namespace detail
89 namespace traits {
90 
91 template <typename T, typename Property, typename>
92 struct query_static_constexpr_member_default :
94 {
95 };
96 
97 template <typename T, typename Property, typename>
98 struct query_static_constexpr_member :
99  query_static_constexpr_member_default<T, Property>
100 {
101 };
102 
103 } // namespace traits
104 } // namespace asio
105 
106 #include "asio/detail/pop_options.hpp"
107 
108 #endif // ASIO_TRAITS_QUERY_STATIC_CONSTEXPR_MEMBER_HPP
Definition: query_static_constexpr_member.hpp:53
Definition: query_static_constexpr_member.hpp:39
Definition: chrono.h:284
Definition: query_static_constexpr_member.hpp:47
Definition: query_static_constexpr_member.hpp:42
Definition: any_io_executor.hpp:28