Clementine
static_query.hpp
1 //
2 // traits/static_query.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_STATIC_QUERY_HPP
12 #define ASIO_TRAITS_STATIC_QUERY_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_VARIABLE_TEMPLATES) \
25  && defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
26 # define ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT 1
27 #endif // defined(ASIO_HAS_DECLTYPE)
28  // && defined(ASIO_HAS_NOEXCEPT)
29  // && defined(ASIO_HAS_CONSTEXPR)
30  // && defined(ASIO_HAS_VARIABLE_TEMPLATES)
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>
42 struct static_query;
43 
44 } // namespace traits
45 namespace detail {
46 
48 {
49  ASIO_STATIC_CONSTEXPR(bool, is_valid = false);
50  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
51 };
52 
53 template <typename T, typename Property, typename = void>
55  conditional<
56  is_same<T, typename decay<T>::type>::value
57  && is_same<Property, typename decay<Property>::type>::value,
58  no_static_query,
59  traits::static_query<
60  typename decay<T>::type,
61  typename decay<Property>::type>
62  >::type
63 {
64 };
65 
66 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
67 
68 template <typename T, typename Property>
69 struct static_query_trait<T, Property,
70  typename void_type<
71  decltype(decay<Property>::type::template static_query_v<T>)
72  >::type>
73 {
74  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
75 
76  using result_type = decltype(
77  decay<Property>::type::template static_query_v<T>);
78 
79  ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
80  noexcept(decay<Property>::type::template static_query_v<T>));
81 
82  static ASIO_CONSTEXPR result_type value() noexcept(is_noexcept)
83  {
84  return decay<Property>::type::template static_query_v<T>;
85  }
86 };
87 
88 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
89 
90 } // namespace detail
91 namespace traits {
92 
93 template <typename T, typename Property, typename>
94 struct static_query_default : detail::static_query_trait<T, Property>
95 {
96 };
97 
98 template <typename T, typename Property, typename>
99 struct static_query : static_query_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_STATIC_QUERY_HPP
Definition: static_query.hpp:42
Definition: chrono.h:284
Definition: static_query.hpp:54
Definition: static_query.hpp:47
Definition: any_io_executor.hpp:28
Definition: static_query.hpp:39