-
Notifications
You must be signed in to change notification settings - Fork 322
Fix __query_or CPO
#7266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix __query_or CPO
#7266
Conversation
8e6b67a to
6d36804
Compare
|
pre-commit.ci autofix |
|
today, given a query
today, the current semantics of struct get_allocator_t {
template <class Env>
auto query(const Env& env, auto&&...) const noexcept {
return __query_or(env, *this, std::allocator<std::byte>());
}
};the change proposed here would make this infinitely recurse. would a |
I am impartial to what solution we use, but we need one that we can use uniformly in CCCL |
| _CCCL_REQUIRES(__queryable_with<_Env, _Query, _Args...>) | ||
| [[nodiscard]] _CCCL_API constexpr auto operator()(const _Env& __env, _Query, _Default&&, _Args&&... __args) const | ||
| noexcept(__nothrow_queryable_with<_Env, _Query, _Args...>) -> __query_result_t<_Env, _Query, _Args...> | ||
| _CCCL_REQUIRES(__queryable_with<const _Env&, _Query, _Args...>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ericniebler I believe that is a bugfix, because a query with a non-const query method would satisfy __queryable_with<_Env, _Query, _Args...> but cannot be called here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true. a different fix would be for __queryable_with and friends to automatically const & qualify the Env argument.
We want to be able to also handle fallbacks, so add those CPOs
1b6ef2b to
17039be
Compare
This is exactly what happened when I was trying a similar approach in #7113 |
|
Btw, #7278 will add a bunch of tests for extracting streams from environments in CUB. |
This comment has been minimized.
This comment has been minimized.
😬 CI Workflow Results🟥 Finished in 1h 46m: Pass: 95%/126 | Total: 1d 20h | Max: 1h 46m | Hits: 99%/250281See results here. |
The
__query_orcurrently requires that the query is always of the formenv.query(CPO, args...)However, we also want that to work with types that are their own query, which would satisfy
cpo(env, args...)This is the case for
::cuda::get_stream(::cudaStream_t)and also for our memory resources