Skip to content

Conversation

@miscco
Copy link
Contributor

@miscco miscco commented Jan 16, 2026

The __query_or currently requires that the query is always of the form env.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

@miscco miscco requested a review from a team as a code owner January 16, 2026 08:48
@miscco miscco requested a review from davebayer January 16, 2026 08:48
@github-project-automation github-project-automation bot moved this to Todo in CCCL Jan 16, 2026
@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL Jan 16, 2026
@miscco miscco requested a review from ericniebler January 16, 2026 08:48
@miscco miscco force-pushed the fix__query_or branch 2 times, most recently from 8e6b67a to 6d36804 Compare January 16, 2026 09:54
@davebayer
Copy link
Contributor

pre-commit.ci autofix

@ericniebler
Copy link
Contributor

ericniebler commented Jan 16, 2026

today, given a query q and an env, there are two reasons why q(env) might be well-formed:

  1. env.query(q) is well-formed, or
  2. q has a fallback that returns a default value

today, __query_or is useful because it distinguishes between these cases. this change breaks that property.

the current semantics of __query_or also make it useful for implementing queries. get_allocator_t might look like this:

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 __call_or or __invoke_or function, or a __with_default callable adaptor, meet your needs?

@miscco
Copy link
Contributor Author

miscco commented Jan 16, 2026

would a __call_or or __invoke_or function, or a __with_default callable adaptor, meet your needs?

I am impartial to what solution we use, but we need one that we can use uniformly in CCCL

@miscco miscco requested a review from a team as a code owner January 16, 2026 18:37
@miscco miscco requested a review from NaderAlAwar January 16, 2026 18:37
_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...>)
Copy link
Contributor Author

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

Copy link
Contributor

@ericniebler ericniebler Jan 16, 2026

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.

@miscco miscco enabled auto-merge (squash) January 16, 2026 18:44
@miscco miscco disabled auto-merge January 16, 2026 18:44
We want to be able to also handle fallbacks, so add those CPOs
@pciolkosz
Copy link
Contributor

the change proposed here would make this infinitely recurse.

This is exactly what happened when I was trying a similar approach in #7113

@bernhardmgruber
Copy link
Contributor

Btw, #7278 will add a bunch of tests for extracting streams from environments in CUB.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

😬 CI Workflow Results

🟥 Finished in 1h 46m: Pass: 95%/126 | Total: 1d 20h | Max: 1h 46m | Hits: 99%/250281

See results here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

5 participants