// execution/blocking_adaptation.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
- is_applicable_property_v = is_executor<T>::value
- || is_sender<T>::value || is_scheduler<T>::value);
+ is_applicable_property_v = (
+ is_executor<T>::value
+ || conditional<
+ is_executor<T>::value,
+ false_type,
+ is_sender<T>
+ >::type::value
+ || conditional<
+ is_executor<T>::value,
+ false_type,
+ is_scheduler<T>
+ >::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = false);
{
}
+ template <typename T>
+ struct proxy
+ {
+#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
+ struct type
+ {
+ template <typename P>
+ auto query(BOOST_ASIO_MOVE_ARG(P) p) const
+ noexcept(
+ noexcept(
+ declval<typename conditional<true, T, P>::type>().query(
+ BOOST_ASIO_MOVE_CAST(P)(p))
+ )
+ )
+ -> decltype(
+ declval<typename conditional<true, T, P>::type>().query(
+ BOOST_ASIO_MOVE_CAST(P)(p))
+ );
+ };
+#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
+ typedef T type;
+#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
+ };
+
+ template <typename T>
+ struct static_proxy
+ {
+#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
+ struct type
+ {
+ template <typename P>
+ static constexpr auto query(BOOST_ASIO_MOVE_ARG(P) p)
+ noexcept(
+ noexcept(
+ conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
+ )
+ )
+ -> decltype(
+ conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
+ )
+ {
+ return T::query(BOOST_ASIO_MOVE_CAST(P)(p));
+ }
+ };
+#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
+ typedef T type;
+#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
+ };
+
+ template <typename T>
+ struct query_member :
+ traits::query_member<typename proxy<T>::type, blocking_adaptation_t> {};
+
+ template <typename T>
+ struct query_static_constexpr_member :
+ traits::query_static_constexpr_member<
+ typename static_proxy<T>::type, blocking_adaptation_t> {};
+
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
- typename traits::query_static_constexpr_member<
- T, blocking_adaptation_t>::result_type
+ typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
- traits::query_static_constexpr_member<
- T, blocking_adaptation_t
- >::is_noexcept))
+ query_static_constexpr_member<T>::is_noexcept))
{
- return traits::query_static_constexpr_member<
- T, blocking_adaptation_t>::value();
+ return query_static_constexpr_member<T>::value();
}
template <typename T>
typename traits::static_query<T, disallowed_t>::result_type
static_query(
typename enable_if<
- !traits::query_static_constexpr_member<
- T, blocking_adaptation_t>::is_valid
- && !traits::query_member<T, blocking_adaptation_t>::is_valid
- && traits::static_query<T, disallowed_t>::is_valid
+ !query_static_constexpr_member<T>::is_valid
+ >::type* = 0,
+ typename enable_if<
+ !query_member<T>::is_valid
+ >::type* = 0,
+ typename enable_if<
+ traits::static_query<T, disallowed_t>::is_valid
>::type* = 0) BOOST_ASIO_NOEXCEPT
{
return traits::static_query<T, disallowed_t>::value();
typename traits::static_query<T, allowed_t>::result_type
static_query(
typename enable_if<
- !traits::query_static_constexpr_member<
- T, blocking_adaptation_t>::is_valid
- && !traits::query_member<T, blocking_adaptation_t>::is_valid
- && !traits::static_query<T, disallowed_t>::is_valid
- && traits::static_query<T, allowed_t>::is_valid
+ !query_static_constexpr_member<T>::is_valid
+ >::type* = 0,
+ typename enable_if<
+ !query_member<T>::is_valid
+ >::type* = 0,
+ typename enable_if<
+ !traits::static_query<T, disallowed_t>::is_valid
+ >::type* = 0,
+ typename enable_if<
+ traits::static_query<T, allowed_t>::is_valid
>::type* = 0) BOOST_ASIO_NOEXCEPT
{
return traits::static_query<T, allowed_t>::value();
const Executor& ex, convertible_from_blocking_adaptation_t,
typename enable_if<
!can_query<const Executor&, disallowed_t>::value
- && can_query<const Executor&, allowed_t>::value
+ >::type* = 0,
+ typename enable_if<
+ can_query<const Executor&, allowed_t>::value
>::type* = 0)
#if !defined(__clang__) // Clang crashes if noexcept is used here.
#if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
- is_applicable_property_v = is_executor<T>::value
- || is_sender<T>::value || is_scheduler<T>::value);
+ is_applicable_property_v = (
+ is_executor<T>::value
+ || conditional<
+ is_executor<T>::value,
+ false_type,
+ is_sender<T>
+ >::type::value
+ || conditional<
+ is_executor<T>::value,
+ false_type,
+ is_scheduler<T>
+ >::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = true);
{
}
+ template <typename T>
+ struct query_member :
+ traits::query_member<
+ typename blocking_adaptation_t<I>::template proxy<T>::type,
+ disallowed_t> {};
+
+ template <typename T>
+ struct query_static_constexpr_member :
+ traits::query_static_constexpr_member<
+ typename blocking_adaptation_t<I>::template static_proxy<T>::type,
+ disallowed_t> {};
+
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
- typename traits::query_static_constexpr_member<T, disallowed_t>::result_type
+ typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
- traits::query_static_constexpr_member<T, disallowed_t>::is_noexcept))
+ query_static_constexpr_member<T>::is_noexcept))
{
- return traits::query_static_constexpr_member<T, disallowed_t>::value();
+ return query_static_constexpr_member<T>::value();
}
template <typename T>
static BOOST_ASIO_CONSTEXPR disallowed_t static_query(
typename enable_if<
- !traits::query_static_constexpr_member<T, disallowed_t>::is_valid
- && !traits::query_member<T, disallowed_t>::is_valid
- && !traits::query_free<T, disallowed_t>::is_valid
- && !can_query<T, allowed_t<I> >::value
+ !query_static_constexpr_member<T>::is_valid
+ >::type* = 0,
+ typename enable_if<
+ !query_member<T>::is_valid
+ >::type* = 0,
+ typename enable_if<
+ !traits::query_free<T, disallowed_t>::is_valid
+ >::type* = 0,
+ typename enable_if<
+ !can_query<T, allowed_t<I> >::value
>::type* = 0) BOOST_ASIO_NOEXCEPT
{
return disallowed_t();
#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
template <typename T>
BOOST_ASIO_STATIC_CONSTEXPR(bool,
- is_applicable_property_v = is_executor<T>::value
- || is_sender<T>::value || is_scheduler<T>::value);
+ is_applicable_property_v = (
+ is_executor<T>::value
+ || conditional<
+ is_executor<T>::value,
+ false_type,
+ is_sender<T>
+ >::type::value
+ || conditional<
+ is_executor<T>::value,
+ false_type,
+ is_scheduler<T>
+ >::type::value));
#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = true);
{
}
+ template <typename T>
+ struct query_member :
+ traits::query_member<
+ typename blocking_adaptation_t<I>::template proxy<T>::type,
+ allowed_t> {};
+
+ template <typename T>
+ struct query_static_constexpr_member :
+ traits::query_static_constexpr_member<
+ typename blocking_adaptation_t<I>::template static_proxy<T>::type,
+ allowed_t> {};
+
#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static BOOST_ASIO_CONSTEXPR
- typename traits::query_static_constexpr_member<T, allowed_t>::result_type
+ typename query_static_constexpr_member<T>::result_type
static_query()
BOOST_ASIO_NOEXCEPT_IF((
- traits::query_static_constexpr_member<T, allowed_t>::is_noexcept))
+ query_static_constexpr_member<T>::is_noexcept))
{
- return traits::query_static_constexpr_member<T, allowed_t>::value();
+ return query_static_constexpr_member<T>::value();
}
template <typename E, typename T = decltype(allowed_t::static_query<E>())>
struct is_applicable_property<T, execution::blocking_adaptation_t>
: integral_constant<bool,
execution::is_executor<T>::value
- || execution::is_sender<T>::value
- || execution::is_scheduler<T>::value>
+ || conditional<
+ execution::is_executor<T>::value,
+ false_type,
+ execution::is_sender<T>
+ >::type::value
+ || conditional<
+ execution::is_executor<T>::value,
+ false_type,
+ execution::is_scheduler<T>
+ >::type::value>
{
};
struct is_applicable_property<T, execution::blocking_adaptation_t::disallowed_t>
: integral_constant<bool,
execution::is_executor<T>::value
- || execution::is_sender<T>::value
- || execution::is_scheduler<T>::value>
+ || conditional<
+ execution::is_executor<T>::value,
+ false_type,
+ execution::is_sender<T>
+ >::type::value
+ || conditional<
+ execution::is_executor<T>::value,
+ false_type,
+ execution::is_scheduler<T>
+ >::type::value>
{
};
struct is_applicable_property<T, execution::blocking_adaptation_t::allowed_t>
: integral_constant<bool,
execution::is_executor<T>::value
- || execution::is_sender<T>::value
- || execution::is_scheduler<T>::value>
+ || conditional<
+ execution::is_executor<T>::value,
+ false_type,
+ execution::is_sender<T>
+ >::type::value
+ || conditional<
+ execution::is_executor<T>::value,
+ false_type,
+ execution::is_scheduler<T>
+ >::type::value>
{
};
template <typename T>
struct static_query<T, execution::blocking_adaptation_t,
typename enable_if<
- traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t>::is_valid
+ execution::detail::blocking_adaptation_t<0>::
+ query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
- typedef typename traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t>::result_type result_type;
+ typedef typename execution::detail::blocking_adaptation_t<0>::
+ query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
- return traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t>::value();
+ return execution::detail::blocking_adaptation_t<0>::
+ query_static_constexpr_member<T>::value();
}
};
template <typename T>
struct static_query<T, execution::blocking_adaptation_t,
typename enable_if<
- !traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t>::is_valid
- && !traits::query_member<T,
- execution::blocking_adaptation_t>::is_valid
+ !execution::detail::blocking_adaptation_t<0>::
+ query_static_constexpr_member<T>::is_valid
+ && !execution::detail::blocking_adaptation_t<0>::
+ query_member<T>::is_valid
&& traits::static_query<T,
execution::blocking_adaptation_t::disallowed_t>::is_valid
>::type>
template <typename T>
struct static_query<T, execution::blocking_adaptation_t,
typename enable_if<
- !traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t>::is_valid
- && !traits::query_member<T,
- execution::blocking_adaptation_t>::is_valid
+ !execution::detail::blocking_adaptation_t<0>::
+ query_static_constexpr_member<T>::is_valid
+ && !execution::detail::blocking_adaptation_t<0>::
+ query_member<T>::is_valid
&& !traits::static_query<T,
execution::blocking_adaptation_t::disallowed_t>::is_valid
&& traits::static_query<T,
template <typename T>
struct static_query<T, execution::blocking_adaptation_t::disallowed_t,
typename enable_if<
- traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t::disallowed_t>::is_valid
+ execution::detail::blocking_adaptation::disallowed_t<0>::
+ query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
- typedef typename traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t::disallowed_t>::result_type result_type;
+ typedef typename execution::detail::blocking_adaptation::disallowed_t<0>::
+ query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
- return traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t::disallowed_t>::value();
+ return execution::detail::blocking_adaptation::disallowed_t<0>::
+ query_static_constexpr_member<T>::value();
}
};
template <typename T>
struct static_query<T, execution::blocking_adaptation_t::disallowed_t,
typename enable_if<
- !traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t::disallowed_t>::is_valid
- && !traits::query_member<T,
- execution::blocking_adaptation_t::disallowed_t>::is_valid
+ !execution::detail::blocking_adaptation::disallowed_t<0>::
+ query_static_constexpr_member<T>::is_valid
+ && !execution::detail::blocking_adaptation::disallowed_t<0>::
+ query_member<T>::is_valid
&& !traits::query_free<T,
execution::blocking_adaptation_t::disallowed_t>::is_valid
&& !can_query<T, execution::blocking_adaptation_t::allowed_t>::value
template <typename T>
struct static_query<T, execution::blocking_adaptation_t::allowed_t,
typename enable_if<
- traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t::allowed_t>::is_valid
+ execution::detail::blocking_adaptation::allowed_t<0>::
+ query_static_constexpr_member<T>::is_valid
>::type>
{
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
- typedef typename traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t::allowed_t>::result_type result_type;
+ typedef typename execution::detail::blocking_adaptation::allowed_t<0>::
+ query_static_constexpr_member<T>::result_type result_type;
static BOOST_ASIO_CONSTEXPR result_type value()
{
- return traits::query_static_constexpr_member<T,
- execution::blocking_adaptation_t::allowed_t>::value();
+ return execution::detail::blocking_adaptation::allowed_t<0>::
+ query_static_constexpr_member<T>::value();
}
};