Skip to content

extend the concept portability macros to support _Convertible_to(T) and _Derived_from(T)#8768

Open
ericniebler wants to merge 2 commits intoNVIDIA:mainfrom
ericniebler:convertible-to-and-derived-from-concept-emulation-macros
Open

extend the concept portability macros to support _Convertible_to(T) and _Derived_from(T)#8768
ericniebler wants to merge 2 commits intoNVIDIA:mainfrom
ericniebler:convertible-to-and-derived-from-concept-emulation-macros

Conversation

@ericniebler
Copy link
Copy Markdown
Contributor

Description

in private conversation, @miscco mentioned that he wanted a _Convertible_to extension to the concept portability macros so that he could replace:

template <class T>
_CCCL_CONCEPT fooable =
  _CCCL_REQUIRES_EXPR((T), T& value)(
    requires(cuda::std::convertible_to<decltype(some_expression(value)), U>)
  );

with

template <class T>
_CCCL_CONCEPT fooable =
  _CCCL_REQUIRES_EXPR((T), T& value)(
    _Convertible_to(U) some_expression(value)
  );

for good measure this PR also adds a _Derived_from macro, which i have wanted at times.

finally, this PR makes use of the new macros in cuda/__algorithm/common.h.

Checklist

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

@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot Bot commented Apr 30, 2026

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 Apr 30, 2026
@ericniebler
Copy link
Copy Markdown
Contributor Author

/ok to test d74e764

@ericniebler
Copy link
Copy Markdown
Contributor Author

/ok to test 804f994

@github-actions
Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 29m: Pass: 100%/110 | Total: 2d 01h | Max: 2h 28m | Hits: 82%/316700

See results here.

@ericniebler ericniebler marked this pull request as ready for review April 30, 2026 22:43
@ericniebler ericniebler requested a review from a team as a code owner April 30, 2026 22:43
@ericniebler ericniebler requested a review from wmaxey April 30, 2026 22:43
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Apr 30, 2026
@ericniebler ericniebler requested a review from miscco April 30, 2026 22:52
// Converts "_Same_as(TYPE) EXPR..." to "decltype(EXPR...), TYPE"
# define _CCCL_CONCEPT_SAME_AS_REQUIREMENT_(_REQ) \
_CCCL_CONCEPT_GET_TYPE_FROM_SAME_AS_(_REQ), decltype(_CCCL_CONCEPT_EAT_SAME_AS_(_REQ))
decltype(_CCCL_CONCEPT_EAT_SAME_AS_(_REQ)), _CCCL_CONCEPT_GET_TYPE_FROM_SAME_AS_(_REQ)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the swap?

Copy link
Copy Markdown
Contributor Author

@ericniebler ericniebler May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for consistency with the argument order for the _Derived_from and _Convertible_to cases

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.

2 participants