Skip to content

Conversation

@ericniebler
Copy link
Contributor

Description

when writing a concept definition in CCCL today, if you want to portably test whether a particular expression satisfies a given concept, you have to write it like:

_CCCL_REQUIRES_EXPR((T), T& t)
(
  requires(my_concept<decltype(some-expression)>)
)

in c++20, this expands to:

requires(T& t)
{
  requires my_concept<decltype(some-expression)>;
}

but that is not how you would write it in c++20, and the above formulation gives worse diagnostics than the more idiomatic:

requires(T& t)
{
  {some-expression} -> my_concept;
}

this pr adds a new _Satisfies requirement kind to CCCL's concept portability macros. it would be used like this:

_CCCL_REQUIRES_EXPR((T), T& t)
(
  _Satisfies(my_concept) some-expression
)

in c++20, this expands to the more idiomatic formulation

this pr also changes the equality_comparable and totally_ordered concepts to use _Satisfies.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Dec 4, 2025

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Progress in CCCL Dec 4, 2025
@ericniebler
Copy link
Contributor Author

/ok to test a59ca7e

@ericniebler ericniebler marked this pull request as ready for review December 4, 2025 23:46
@ericniebler ericniebler requested a review from a team as a code owner December 4, 2025 23:46
@ericniebler ericniebler requested a review from griwes December 4, 2025 23:46
@cccl-authenticator-app cccl-authenticator-app bot moved this from In Progress to In Review in CCCL Dec 4, 2025
@ericniebler ericniebler enabled auto-merge (squash) December 5, 2025 00:02
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🥳 CI Workflow Results

🟩 Finished in 3h 14m: Pass: 100%/91 | Total: 2d 18h | Max: 3h 12m | Hits: 61%/208416

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.

1 participant