Add friendship support to execution::blocking_adaptation property.

This commit is contained in:
Christopher Kohlhoff 2021-01-06 22:48:19 +11:00
parent 55df45012d
commit 0106229b7e

View File

@ -202,20 +202,74 @@ struct blocking_adaptation_t
{
}
template <typename T>
struct proxy
{
#if defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
struct type
{
template <typename P>
auto query(ASIO_MOVE_ARG(P) p) const
noexcept(
noexcept(
declval<typename conditional<true, T, P>::type>().query(
ASIO_MOVE_CAST(P)(p))
)
)
-> decltype(
declval<typename conditional<true, T, P>::type>().query(
ASIO_MOVE_CAST(P)(p))
);
};
#else // defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
typedef T type;
#endif // defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
};
template <typename T>
struct static_proxy
{
#if defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
struct type
{
template <typename P>
static constexpr auto query(ASIO_MOVE_ARG(P) p)
noexcept(
noexcept(
conditional<true, T, P>::type::query(ASIO_MOVE_CAST(P)(p))
)
)
-> decltype(
conditional<true, T, P>::type::query(ASIO_MOVE_CAST(P)(p))
)
{
return T::query(ASIO_MOVE_CAST(P)(p));
}
};
#else // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
typedef T type;
#endif // defined(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(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static ASIO_CONSTEXPR
typename traits::query_static_constexpr_member<
T, blocking_adaptation_t>::result_type
typename query_static_constexpr_member<T>::result_type
static_query()
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>
@ -223,11 +277,10 @@ struct blocking_adaptation_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
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::query_member<T, blocking_adaptation_t>::is_valid
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
traits::static_query<T, disallowed_t>::is_valid
@ -241,11 +294,10 @@ struct blocking_adaptation_t
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
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::query_member<T, blocking_adaptation_t>::is_valid
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::static_query<T, disallowed_t>::is_valid
@ -388,25 +440,37 @@ struct disallowed_t
{
}
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(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static ASIO_CONSTEXPR
typename traits::query_static_constexpr_member<T, disallowed_t>::result_type
typename query_static_constexpr_member<T>::result_type
static_query()
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 ASIO_CONSTEXPR disallowed_t static_query(
typename enable_if<
!traits::query_static_constexpr_member<T, disallowed_t>::is_valid
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::query_member<T, disallowed_t>::is_valid
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::query_free<T, disallowed_t>::is_valid
@ -588,16 +652,28 @@ struct allowed_t
{
}
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(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
&& defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
template <typename T>
static ASIO_CONSTEXPR
typename traits::query_static_constexpr_member<T, allowed_t>::result_type
typename query_static_constexpr_member<T>::result_type
static_query()
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>())>
@ -809,30 +885,30 @@ struct query_free_default<T, execution::blocking_adaptation_t,
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>
{
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
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 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>
@ -853,10 +929,10 @@ struct static_query<T, execution::blocking_adaptation_t,
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,
@ -879,30 +955,30 @@ struct static_query<T, execution::blocking_adaptation_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>
{
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
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 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
@ -922,20 +998,20 @@ struct static_query<T, execution::blocking_adaptation_t::disallowed_t,
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>
{
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
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 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();
}
};