Skip to content

Commit 259dae9

Browse files
committed
remove unnecessary indirection through __query template
Replace `__query<Tag>()(env, args...)` with `env.query(Tag(), args...)` now that we no longer need to handle environments that use `tag_invoke` instead of the `.query` member function.
1 parent d277c31 commit 259dae9

10 files changed

Lines changed: 70 additions & 78 deletions

File tree

‎include/exec/env.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace experimental::execution
5151
noexcept(STDEXEC::__nothrow_queryable_with<_Env, _OtherQuery, _Args...>)
5252
-> STDEXEC::__query_result_t<_Env, _OtherQuery, _Args...>
5353
{
54-
return STDEXEC::__query<_OtherQuery>()(__env_, static_cast<_Args&&>(__args)...);
54+
return _OtherQuery()(__env_, static_cast<_Args&&>(__args)...);
5555
}
5656

5757
STDEXEC_ATTRIBUTE(no_unique_address)

‎include/exec/thread_pool_base.hpp‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,14 @@ namespace experimental::execution
494494

495495
struct attrs
496496
{
497-
template <STDEXEC::__forwarding_query Tag, class... As>
498-
requires STDEXEC::__queryable_with<STDEXEC::env_of_t<Sender>, Tag, As...>
497+
template <class _Env2 = STDEXEC::env_of_t<Sender>,
498+
STDEXEC::__forwarding_query Tag,
499+
class... As>
500+
requires STDEXEC::__queryable_with<_Env2, Tag, As...>
499501
auto query(Tag, As&&... as) const
500-
noexcept(STDEXEC::__nothrow_queryable_with<STDEXEC::env_of_t<Sender>, Tag, As...>)
501-
-> decltype(auto)
502+
noexcept(STDEXEC::__nothrow_queryable_with<_Env2, Tag, As...>) -> decltype(auto)
502503
{
503-
return STDEXEC::__query<Tag>()(STDEXEC::get_env(sndr_.sndr_), static_cast<As&&>(as)...);
504+
return STDEXEC::get_env(sndr_.sndr_).query(Tag(), static_cast<As&&>(as)...);
504505
}
505506

506507
bulk_sender const & sndr_;

‎include/nvexec/stream/common.cuh‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,13 +460,13 @@ namespace nv::execution
460460
template <class Sender>
461461
struct stream_sender_attrs
462462
{
463-
template <__forwarding_query Query>
464-
requires __queryable_with<env_of_t<Sender>, Query>
463+
template <class _Env2 = env_of_t<Sender>, class __forwarding_query Query>
464+
requires __queryable_with<_Env2, Query>
465465
STDEXEC_ATTRIBUTE(nodiscard)
466-
constexpr auto query(Query) const noexcept(__nothrow_queryable_with<env_of_t<Sender>, Query>)
467-
-> __query_result_t<env_of_t<Sender>, Query>
466+
constexpr auto query(Query) const noexcept(__nothrow_queryable_with<_Env2, Query>)
467+
-> __query_result_t<_Env2, Query>
468468
{
469-
return STDEXEC::__query<Query>()(STDEXEC::get_env(*child_));
469+
return STDEXEC::get_env(*child_).query(Query());
470470
}
471471

472472
Sender const * child_{};

‎include/stdexec/__detail/__completion_behavior.hpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ namespace STDEXEC
155155
STDEXEC_ATTRIBUTE(always_inline, host, device)
156156
static constexpr auto __validate() noexcept
157157
{
158-
using __result_t = __member_query_result_t<_Attrs, __get_completion_behavior_t, _Env...>;
159-
static_assert(__nothrow_member_queryable_with<_Attrs, __get_completion_behavior_t, _Env...>,
158+
using __result_t = __query_result_t<_Attrs, __get_completion_behavior_t, _Env...>;
159+
static_assert(__nothrow_queryable_with<_Attrs, __get_completion_behavior_t, _Env...>,
160160
"The __get_completion_behavior query must be noexcept.");
161161
static_assert(__std::convertible_to<__result_t, __completion_behavior::__behavior>,
162162
"The __get_completion_behavior query must return one of the static member "
@@ -172,7 +172,7 @@ namespace STDEXEC
172172
STDEXEC_ATTRIBUTE(nodiscard, always_inline, host, device)
173173
constexpr auto operator()(_Attrs const &) const noexcept
174174
{
175-
if constexpr (__member_queryable_with<_Attrs const &, __get_completion_behavior_t<_Tag>>)
175+
if constexpr (__queryable_with<_Attrs const &, __get_completion_behavior_t<_Tag>>)
176176
{
177177
return __validate<_Attrs>();
178178
}
@@ -186,9 +186,9 @@ namespace STDEXEC
186186
STDEXEC_ATTRIBUTE(nodiscard, always_inline, host, device)
187187
constexpr auto operator()([[maybe_unused]] _Attrs const &__attrs, _Env const &) const noexcept
188188
{
189-
if constexpr (__member_queryable_with<_Attrs const &,
190-
__get_completion_behavior_t<_Tag>,
191-
_Env const &>)
189+
if constexpr (__queryable_with<_Attrs const &,
190+
__get_completion_behavior_t<_Tag>,
191+
_Env const &>)
192192
{
193193
return __validate<_Attrs, _Env>();
194194
}

‎include/stdexec/__detail/__domain.hpp‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ namespace STDEXEC
226226
: __env_{static_cast<_Env &&>(__env)}
227227
{}
228228

229-
template <__none_of<_Queries...> _Query, class... _As>
230-
requires __queryable_with<_Env, _Query, _As...>
231-
constexpr auto
232-
operator()(_Query, _As &&...__as) const noexcept(__nothrow_queryable_with<_Env, _Query, _As...>)
233-
-> __query_result_t<_Env, _Query, _As...>
229+
template <class _Env2 = _Env, __none_of<_Queries...> _Query, class... _As>
230+
requires __queryable_with<_Env2, _Query, _As...>
231+
constexpr auto operator()(_Query, _As &&...__as) const
232+
noexcept(__nothrow_queryable_with<_Env2, _Query, _As...>)
233+
-> __query_result_t<_Env2, _Query, _As...>
234234
{
235-
return __query<_Query>()(__env_, static_cast<_As &&>(__as)...);
235+
return __env_.query(_Query(), static_cast<_As &&>(__as)...);
236236
}
237237

238238
private:
@@ -430,9 +430,9 @@ namespace STDEXEC
430430
STDEXEC_ATTRIBUTE(nodiscard, always_inline, host, device)
431431
constexpr auto operator()(_Env const &) const noexcept -> auto
432432
{
433-
if constexpr (__member_queryable_with<_Env const &, get_domain_t>)
433+
if constexpr (__queryable_with<_Env const &, get_domain_t>)
434434
{
435-
return __decay_t<__member_query_result_t<_Env, get_domain_t>>{};
435+
return __decay_t<__query_result_t<_Env, get_domain_t>>{};
436436
}
437437
else if constexpr (__callable<get_start_scheduler_t, _Env const &>)
438438
{

‎include/stdexec/__detail/__env.hpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ namespace STDEXEC
6565
{
6666
static_assert(__nothrow_move_constructible<_Env>);
6767

68-
template <__forwarding_query _Query, class... _Args>
69-
requires __queryable_with<_Env, _Query, _Args...>
68+
template <class _Env2 = _Env, __forwarding_query _Query, class... _Args>
69+
requires __queryable_with<_Env2, _Query, _Args...>
7070
STDEXEC_ATTRIBUTE(nodiscard, always_inline, host, device)
7171
constexpr auto query(_Query, _Args &&...__args) const
72-
noexcept(__nothrow_queryable_with<_Env, _Query, _Args...>)
73-
-> __query_result_t<_Env, _Query, _Args...>
72+
noexcept(__nothrow_queryable_with<_Env2, _Query, _Args...>)
73+
-> __query_result_t<_Env2, _Query, _Args...>
7474
{
75-
return __query<_Query>()(__env_, static_cast<_Args &&>(__args)...);
75+
return __env_.query(_Query(), static_cast<_Args &&>(__args)...);
7676
}
7777

7878
STDEXEC_ATTRIBUTE(no_unique_address)
@@ -265,7 +265,7 @@ namespace STDEXEC
265265
-> __query_result_t<__1st_env_t<_Query, _Args...>, _Query, _Args...>
266266
{
267267
auto const &__env = __detail::__get_1st_env<_Query, _Args...>()(*this);
268-
return __query<_Query>()(__env, static_cast<_Args &&>(__args)...);
268+
return __env.query(_Query(), static_cast<_Args &&>(__args)...);
269269
}
270270
};
271271

‎include/stdexec/__detail/__queries.hpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ namespace STDEXEC
6767
return __get_completion_behavior<_Tag, _Sender, _Env...>();
6868
}
6969

70-
template <__forwarding_query _Query, class... _Args>
71-
requires __queryable_with<env_of_t<_Sender>, _Query, _Args...>
70+
template <class _Env2 = env_of_t<_Sender>, __forwarding_query _Query, class... _Args>
71+
requires __queryable_with<_Env2, _Query, _Args...>
7272
[[nodiscard]]
7373
constexpr auto query(_Query, _Args &&...__args) const
74-
noexcept(__nothrow_queryable_with<env_of_t<_Sender>, _Query, _Args...>)
75-
-> __query_result_t<env_of_t<_Sender>, _Query, _Args...>
74+
noexcept(__nothrow_queryable_with<_Env2, _Query, _Args...>)
75+
-> __query_result_t<_Env2, _Query, _Args...>
7676
{
77-
return __query<_Query>()(get_env(__sndr_), static_cast<_Args &&>(__args)...);
77+
return get_env(__sndr_).query(_Query(), static_cast<_Args &&>(__args)...);
7878
}
7979

8080
_Sender const &__sndr_;

‎include/stdexec/__detail/__query.hpp‎

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,28 @@ namespace STDEXEC
4242
template <class T>
4343
concept __queryable = __std::destructible<T>;
4444

45+
STDEXEC_MODULE_EXPORT_AUTHORING
4546
template <class _Env, class _Query, class... _Args>
46-
concept __member_queryable_with = __queryable<_Env>
47-
&& requires(_Env const &__env,
48-
_Query const &__query,
49-
__declfn_t<_Args &&>... __args) {
50-
{ __env.query(__query, __args()...) };
51-
};
47+
concept __queryable_with = __queryable<_Env>
48+
&& requires(_Env const &__env,
49+
_Query const &__query,
50+
__declfn_t<_Args &&>... __args) {
51+
{ __env.query(__query, __args()...) };
52+
};
5253

54+
STDEXEC_MODULE_EXPORT_AUTHORING
5355
template <class _Env, class _Query, class... _Args>
54-
concept __nothrow_member_queryable_with = __member_queryable_with<_Env, _Query, _Args...>
55-
&& requires(_Env const &__env,
56-
_Query const &__query,
57-
__declfn_t<_Args &&>... __args) {
58-
{ __env.query(__query, __args()...) } noexcept;
59-
};
56+
concept __nothrow_queryable_with = __queryable_with<_Env, _Query, _Args...>
57+
&& requires(_Env const &__env,
58+
_Query const &__query,
59+
__declfn_t<_Args &&>... __args) {
60+
{ __env.query(__query, __args()...) } noexcept;
61+
};
6062

63+
STDEXEC_MODULE_EXPORT_AUTHORING
6164
template <class _Env, class _Qy, class... _Args>
62-
using __member_query_result_t = decltype(__declval<_Env const &>().query(__declval<_Qy const &>(),
63-
__declval<_Args>()...));
65+
using __query_result_t = decltype(__declval<_Env const &>().query(__declval<_Qy const &>(),
66+
__declval<_Args>()...));
6467

6568
inline constexpr __none_such __no_default{};
6669

@@ -92,11 +95,11 @@ namespace STDEXEC
9295

9396
// Query with a .query member function:
9497
template <class _Qy = _Query, class _Env, class... _Args>
95-
requires __member_queryable_with<_Env const &, _Qy, _Args...>
98+
requires __queryable_with<_Env const &, _Qy, _Args...>
9699
STDEXEC_ATTRIBUTE(nodiscard, always_inline, host, device)
97100
constexpr auto operator()(_Env const &__env, _Args &&...__args) const
98-
noexcept(__nothrow_member_queryable_with<_Env, _Qy, _Args...>)
99-
-> __mcall1<_Transform, __member_query_result_t<_Env, _Qy, _Args...>>
101+
noexcept(__nothrow_queryable_with<_Env, _Qy, _Args...>)
102+
-> __mcall1<_Transform, __query_result_t<_Env, _Qy, _Args...>>
100103
{
101104
if constexpr (__has_validation<_Query, _Env, _Args...>)
102105
{
@@ -106,18 +109,6 @@ namespace STDEXEC
106109
}
107110
};
108111

109-
STDEXEC_MODULE_EXPORT_AUTHORING
110-
template <class _Env, class _Query, class... _Args>
111-
concept __queryable_with = __callable<__query<_Query>, _Env &, _Args...>;
112-
113-
STDEXEC_MODULE_EXPORT_AUTHORING
114-
template <class _Env, class _Query, class... _Args>
115-
concept __nothrow_queryable_with = __nothrow_callable<__query<_Query>, _Env &, _Args...>;
116-
117-
STDEXEC_MODULE_EXPORT_AUTHORING
118-
template <class _Env, class _Query, class... _Args>
119-
using __query_result_t = __call_result_t<__query<_Query>, _Env &, _Args...>;
120-
121112
template <class _Env, class _Query, class... _Args>
122113
concept __statically_queryable_with_impl = requires(_Query __q, _Args &&...__args) {
123114
std::remove_reference_t<_Env>::query(__q, static_cast<_Args &&>(__args)...);
@@ -163,7 +154,7 @@ STDEXEC_P2300_NAMESPACE_BEGIN()
163154
{
164155
if constexpr (STDEXEC::__queryable_with<_Query, forwarding_query_t>)
165156
{
166-
return STDEXEC::__query<forwarding_query_t>()(_Query());
157+
return _Query().query(forwarding_query_t());
167158
}
168159
else
169160
{

‎include/stdexec/__detail/__sequence.hpp‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ namespace STDEXEC
7272
template <class _Sender>
7373
struct __attrs<_Sender>
7474
{
75-
template <class _Query, class... _Args>
76-
requires __queryable_with<env_of_t<_Sender>, _Query, _Args...>
75+
template <class _Env2 = env_of_t<_Sender>, class _Query, class... _Args>
76+
requires __queryable_with<_Env2, _Query, _Args...>
7777
STDEXEC_ATTRIBUTE(nodiscard, always_inline, host, device)
7878
constexpr auto operator()(_Query, _Args &&...__args) const
79-
noexcept(__nothrow_queryable_with<env_of_t<_Sender>, _Query, _Args...>)
80-
-> __query_result_t<env_of_t<_Sender>, _Query, _Args...>
79+
noexcept(__nothrow_queryable_with<_Env2, _Query, _Args...>)
80+
-> __query_result_t<_Env2, _Query, _Args...>
8181
{
82-
return __query<_Query>()(STDEXEC::get_env(__sndr_), static_cast<_Args &&>(__args)...);
82+
return STDEXEC::get_env(__sndr_).query(_Query(), static_cast<_Args &&>(__args)...);
8383
}
8484

8585
_Sender __sndr_;
@@ -174,8 +174,8 @@ namespace STDEXEC
174174
noexcept(__nothrow_queryable_with<__joined_t, _Query, _Args...>)
175175
-> __query_result_t<__joined_t, _Query, _Args...>
176176
{
177-
return __query<_Query>()(__joined_t{STDEXEC::get_env(__sndr2_), STDEXEC::get_env(__sndr1_)},
178-
static_cast<_Args &&>(__args)...);
177+
return __joined_t{STDEXEC::get_env(__sndr2_), STDEXEC::get_env(__sndr1_)}
178+
.query(_Query(), static_cast<_Args &&>(__args)...);
179179
}
180180

181181
_Sender1 __sndr1_;

‎include/stdexec/__detail/__task.hpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,14 +1006,14 @@ namespace STDEXEC
10061006
}
10071007
}
10081008

1009-
template <__forwarding_query _Query, class... _Args>
1010-
requires __queryable_with<_TaskEnv, _Query, _Args...>
1009+
template <class _Env2 = _TaskEnv, __forwarding_query _Query, class... _Args>
1010+
requires __queryable_with<_Env2, _Query, _Args...>
10111011
[[nodiscard]]
10121012
constexpr auto query(_Query, _Args&&... __args) const
1013-
noexcept(__nothrow_queryable_with<_TaskEnv, _Query, _Args...>)
1014-
-> __query_result_t<_TaskEnv, _Query, _Args...>
1013+
noexcept(__nothrow_queryable_with<_Env2, _Query, _Args...>)
1014+
-> __query_result_t<_Env2, _Query, _Args...>
10151015
{
1016-
return __query<_Query>()(__promise_->__state_->__env_, static_cast<_Args&&>(__args)...);
1016+
return __promise_->__state_->__env_.query(_Query(), static_cast<_Args&&>(__args)...);
10171017
}
10181018

10191019
__promise const * __promise_;

0 commit comments

Comments
 (0)