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