Add friendship support to execution::mapping property.

This commit is contained in:
Christopher Kohlhoff 2021-01-06 22:55:15 +11:00
parent c541383336
commit 403f559d2c

View File

@ -236,16 +236,74 @@ struct mapping_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, mapping_t> {};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename static_proxy<T>::type, mapping_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, mapping_t>::result_type
typename query_static_constexpr_member<T>::result_type
static_query()
ASIO_NOEXCEPT_IF((
traits::query_static_constexpr_member<T, mapping_t>::is_noexcept))
query_static_constexpr_member<T>::is_noexcept))
{
return traits::query_static_constexpr_member<T, mapping_t>::value();
return query_static_constexpr_member<T>::value();
}
template <typename T>
@ -253,10 +311,10 @@ struct mapping_t
typename traits::static_query<T, thread_t>::result_type
static_query(
typename enable_if<
!traits::query_static_constexpr_member<T, mapping_t>::is_valid
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::query_member<T, mapping_t>::is_valid
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
traits::static_query<T, thread_t>::is_valid
@ -270,10 +328,10 @@ struct mapping_t
typename traits::static_query<T, new_thread_t>::result_type
static_query(
typename enable_if<
!traits::query_static_constexpr_member<T, mapping_t>::is_valid
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::query_member<T, mapping_t>::is_valid
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::static_query<T, thread_t>::is_valid
@ -290,10 +348,10 @@ struct mapping_t
typename traits::static_query<T, other_t>::result_type
static_query(
typename enable_if<
!traits::query_static_constexpr_member<T, mapping_t>::is_valid
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::query_member<T, mapping_t>::is_valid
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::static_query<T, thread_t>::is_valid
@ -460,25 +518,35 @@ struct thread_t
{
}
template <typename T>
struct query_member :
traits::query_member<
typename mapping_t<I>::template proxy<T>::type, thread_t> {};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename mapping_t<I>::template static_proxy<T>::type, thread_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, thread_t>::result_type
typename query_static_constexpr_member<T>::result_type
static_query()
ASIO_NOEXCEPT_IF((
traits::query_static_constexpr_member<T, thread_t>::is_noexcept))
query_static_constexpr_member<T>::is_noexcept))
{
return traits::query_static_constexpr_member<T, thread_t>::value();
return query_static_constexpr_member<T>::value();
}
template <typename T>
static ASIO_CONSTEXPR thread_t static_query(
typename enable_if<
!traits::query_static_constexpr_member<T, thread_t>::is_valid
!query_static_constexpr_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::query_member<T, thread_t>::is_valid
!query_member<T>::is_valid
>::type* = 0,
typename enable_if<
!traits::query_free<T, thread_t>::is_valid
@ -552,16 +620,26 @@ struct new_thread_t
{
}
template <typename T>
struct query_member :
traits::query_member<
typename mapping_t<I>::template proxy<T>::type, new_thread_t> {};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename mapping_t<I>::template static_proxy<T>::type, new_thread_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, new_thread_t>::result_type
typename query_static_constexpr_member<T>::result_type
static_query()
ASIO_NOEXCEPT_IF((
traits::query_static_constexpr_member<T, new_thread_t>::is_noexcept))
query_static_constexpr_member<T>::is_noexcept))
{
return traits::query_static_constexpr_member<T, new_thread_t>::value();
return query_static_constexpr_member<T>::value();
}
template <typename E, typename T = decltype(new_thread_t::static_query<E>())>
@ -623,16 +701,26 @@ struct other_t
{
}
template <typename T>
struct query_member :
traits::query_member<
typename mapping_t<I>::template proxy<T>::type, other_t> {};
template <typename T>
struct query_static_constexpr_member :
traits::query_static_constexpr_member<
typename mapping_t<I>::template static_proxy<T>::type, other_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, other_t>::result_type
typename query_static_constexpr_member<T>::result_type
static_query()
ASIO_NOEXCEPT_IF((
traits::query_static_constexpr_member<T, other_t>::is_noexcept))
query_static_constexpr_member<T>::is_noexcept))
{
return traits::query_static_constexpr_member<T, other_t>::value();
return query_static_constexpr_member<T>::value();
}
template <typename E, typename T = decltype(other_t::static_query<E>())>
@ -805,28 +893,30 @@ struct query_free_default<T, execution::mapping_t,
template <typename T>
struct static_query<T, execution::mapping_t,
typename enable_if<
traits::query_static_constexpr_member<T,
execution::mapping_t>::is_valid
execution::detail::mapping_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::mapping_t>::result_type result_type;
typedef typename execution::detail::mapping_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::mapping_t>::value();
return execution::detail::mapping_t<0>::
query_static_constexpr_member<T>::value();
}
};
template <typename T>
struct static_query<T, execution::mapping_t,
typename enable_if<
!traits::query_static_constexpr_member<T, execution::mapping_t>::is_valid
&& !traits::query_member<T, execution::mapping_t>::is_valid
!execution::detail::mapping_t<0>::
query_static_constexpr_member<T>::is_valid
&& !execution::detail::mapping_t<0>::
query_member<T>::is_valid
&& traits::static_query<T, execution::mapping_t::thread_t>::is_valid
>::type>
{
@ -845,8 +935,10 @@ struct static_query<T, execution::mapping_t,
template <typename T>
struct static_query<T, execution::mapping_t,
typename enable_if<
!traits::query_static_constexpr_member<T, execution::mapping_t>::is_valid
&& !traits::query_member<T, execution::mapping_t>::is_valid
!execution::detail::mapping_t<0>::
query_static_constexpr_member<T>::is_valid
&& !execution::detail::mapping_t<0>::
query_member<T>::is_valid
&& !traits::static_query<T, execution::mapping_t::thread_t>::is_valid
&& traits::static_query<T, execution::mapping_t::new_thread_t>::is_valid
>::type>
@ -866,8 +958,10 @@ struct static_query<T, execution::mapping_t,
template <typename T>
struct static_query<T, execution::mapping_t,
typename enable_if<
!traits::query_static_constexpr_member<T, execution::mapping_t>::is_valid
&& !traits::query_member<T, execution::mapping_t>::is_valid
!execution::detail::mapping_t<0>::
query_static_constexpr_member<T>::is_valid
&& !execution::detail::mapping_t<0>::
query_member<T>::is_valid
&& !traits::static_query<T, execution::mapping_t::thread_t>::is_valid
&& !traits::static_query<T, execution::mapping_t::new_thread_t>::is_valid
&& traits::static_query<T, execution::mapping_t::other_t>::is_valid
@ -888,29 +982,30 @@ struct static_query<T, execution::mapping_t,
template <typename T>
struct static_query<T, execution::mapping_t::thread_t,
typename enable_if<
traits::query_static_constexpr_member<T,
execution::mapping_t::thread_t>::is_valid
execution::detail::mapping::thread_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::mapping_t::thread_t>::result_type result_type;
typedef typename execution::detail::mapping::thread_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::mapping_t::thread_t>::value();
return execution::detail::mapping::thread_t<0>::
query_static_constexpr_member<T>::value();
}
};
template <typename T>
struct static_query<T, execution::mapping_t::thread_t,
typename enable_if<
!traits::query_static_constexpr_member<T,
execution::mapping_t::thread_t>::is_valid
&& !traits::query_member<T, execution::mapping_t::thread_t>::is_valid
!execution::detail::mapping::thread_t<0>::
query_static_constexpr_member<T>::is_valid
&& !execution::detail::mapping::thread_t<0>::
query_member<T>::is_valid
&& !traits::query_free<T, execution::mapping_t::thread_t>::is_valid
&& !can_query<T, execution::mapping_t::new_thread_t>::value
&& !can_query<T, execution::mapping_t::other_t>::value
@ -930,40 +1025,40 @@ struct static_query<T, execution::mapping_t::thread_t,
template <typename T>
struct static_query<T, execution::mapping_t::new_thread_t,
typename enable_if<
traits::query_static_constexpr_member<T,
execution::mapping_t::new_thread_t>::is_valid
execution::detail::mapping::new_thread_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::mapping_t::new_thread_t>::result_type result_type;
typedef typename execution::detail::mapping::new_thread_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::mapping_t::new_thread_t>::value();
return execution::detail::mapping::new_thread_t<0>::
query_static_constexpr_member<T>::value();
}
};
template <typename T>
struct static_query<T, execution::mapping_t::other_t,
typename enable_if<
traits::query_static_constexpr_member<T,
execution::mapping_t::other_t>::is_valid
execution::detail::mapping::other_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::mapping_t::other_t>::result_type result_type;
typedef typename execution::detail::mapping::other_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::mapping_t::other_t>::value();
return execution::detail::mapping::other_t<0>::
query_static_constexpr_member<T>::value();
}
};