File indexing completed on 2024-11-16 09:05:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_EXECUTION_OCCUPANCY_HPP
0012 #define BOOST_ASIO_EXECUTION_OCCUPANCY_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/type_traits.hpp>
0020 #include <boost/asio/execution/executor.hpp>
0021 #include <boost/asio/is_applicable_property.hpp>
0022 #include <boost/asio/traits/query_static_constexpr_member.hpp>
0023 #include <boost/asio/traits/static_query.hpp>
0024
0025 #include <boost/asio/detail/push_options.hpp>
0026
0027 namespace boost {
0028 namespace asio {
0029
0030 #if defined(GENERATING_DOCUMENTATION)
0031
0032 namespace execution {
0033
0034
0035
0036 struct occupancy_t
0037 {
0038
0039 template <typename T>
0040 static constexpr bool is_applicable_property_v = is_executor_v<T>;
0041
0042
0043 static constexpr bool is_requirable = false;
0044
0045
0046 static constexpr bool is_preferable = false;
0047
0048
0049 typedef std::size_t polymorphic_query_result_type;
0050 };
0051
0052
0053 constexpr occupancy_t occupancy;
0054
0055 }
0056
0057 #else
0058
0059 namespace execution {
0060 namespace detail {
0061
0062 template <int I = 0>
0063 struct occupancy_t
0064 {
0065 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0066 template <typename T>
0067 static constexpr bool is_applicable_property_v = is_executor<T>::value;
0068 #endif
0069
0070 static constexpr bool is_requirable = false;
0071 static constexpr bool is_preferable = false;
0072 typedef std::size_t polymorphic_query_result_type;
0073
0074 constexpr occupancy_t()
0075 {
0076 }
0077
0078 template <typename T>
0079 struct static_proxy
0080 {
0081 #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
0082 struct type
0083 {
0084 template <typename P>
0085 static constexpr auto query(P&& p)
0086 noexcept(
0087 noexcept(
0088 conditional_t<true, T, P>::query(static_cast<P&&>(p))
0089 )
0090 )
0091 -> decltype(
0092 conditional_t<true, T, P>::query(static_cast<P&&>(p))
0093 )
0094 {
0095 return T::query(static_cast<P&&>(p));
0096 }
0097 };
0098 #else
0099 typedef T type;
0100 #endif
0101 };
0102
0103 template <typename T>
0104 struct query_static_constexpr_member :
0105 traits::query_static_constexpr_member<
0106 typename static_proxy<T>::type, occupancy_t> {};
0107
0108 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0109 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0110 template <typename T>
0111 static constexpr typename query_static_constexpr_member<T>::result_type
0112 static_query()
0113 noexcept(query_static_constexpr_member<T>::is_noexcept)
0114 {
0115 return query_static_constexpr_member<T>::value();
0116 }
0117
0118 template <typename E, typename T = decltype(occupancy_t::static_query<E>())>
0119 static constexpr const T static_query_v = occupancy_t::static_query<E>();
0120 #endif
0121
0122 };
0123
0124 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0125 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0126 template <int I> template <typename E, typename T>
0127 const T occupancy_t<I>::static_query_v;
0128 #endif
0129
0130
0131 }
0132
0133 typedef detail::occupancy_t<> occupancy_t;
0134
0135 constexpr occupancy_t occupancy;
0136
0137 }
0138
0139 #if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0140
0141 template <typename T>
0142 struct is_applicable_property<T, execution::occupancy_t>
0143 : integral_constant<bool, execution::is_executor<T>::value>
0144 {
0145 };
0146
0147 #endif
0148
0149 namespace traits {
0150
0151 #if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0152 || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0153
0154 template <typename T>
0155 struct static_query<T, execution::occupancy_t,
0156 enable_if_t<
0157 execution::detail::occupancy_t<0>::
0158 query_static_constexpr_member<T>::is_valid
0159 >>
0160 {
0161 static constexpr bool is_valid = true;
0162 static constexpr bool is_noexcept = true;
0163
0164 typedef typename execution::detail::occupancy_t<0>::
0165 query_static_constexpr_member<T>::result_type result_type;
0166
0167 static constexpr result_type value()
0168 {
0169 return execution::detail::occupancy_t<0>::
0170 query_static_constexpr_member<T>::value();
0171 }
0172 };
0173
0174 #endif
0175
0176
0177 }
0178
0179 #endif
0180
0181 }
0182 }
0183
0184 #include <boost/asio/detail/pop_options.hpp>
0185
0186 #endif