Skip to content

[libcu++] Implement tuple-like constructors for tuple#9059

Open
miscco wants to merge 8 commits into
NVIDIA:mainfrom
miscco:tupe_constraints_rewrite
Open

[libcu++] Implement tuple-like constructors for tuple#9059
miscco wants to merge 8 commits into
NVIDIA:mainfrom
miscco:tupe_constraints_rewrite

Conversation

@miscco
Copy link
Copy Markdown
Contributor

@miscco miscco commented May 18, 2026

This refactors the constructor constraints for cuda::std::tuple and implements the new tuple-like constructors

@copy-pr-bot
Copy link
Copy Markdown
Contributor

copy-pr-bot Bot commented May 18, 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 May 18, 2026
@miscco miscco force-pushed the tupe_constraints_rewrite branch from 5a777c9 to fc262c0 Compare May 18, 2026 18:43
@miscco
Copy link
Copy Markdown
Contributor Author

miscco commented May 18, 2026

/ok to test

@miscco miscco force-pushed the tupe_constraints_rewrite branch 2 times, most recently from 305b7ec to c2fb71f Compare May 18, 2026 19:45
@miscco
Copy link
Copy Markdown
Contributor Author

miscco commented May 18, 2026

/ok to test

@github-actions

This comment has been minimized.

@miscco miscco force-pushed the tupe_constraints_rewrite branch from c2fb71f to 93d612c Compare May 21, 2026 08:17
@miscco miscco marked this pull request as ready for review May 21, 2026 09:40
@miscco miscco requested a review from a team as a code owner May 21, 2026 09:40
@miscco miscco requested a review from ericniebler May 21, 2026 09:40
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL May 21, 2026
@miscco
Copy link
Copy Markdown
Contributor Author

miscco commented May 21, 2026

/ok to test

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

important:

Walkthrough

Refactors tuple constraint evaluation to consteval checkers, adds forward-detection traits for pair/tuple/subrange, rebases tuple-like detection, updates tuple constructors/leaf/tuple_cat to use new constraint aliases, and adds test support types plus comprehensive tuple conversion tests.

Changes

Tuple construction and constraint machinery refactor

Layer / File(s) Summary
Type detection traits for CUDA std types
libcudacxx/include/cuda/std/__fwd/pair.h, libcudacxx/include/cuda/std/__fwd/subrange.h, libcudacxx/include/cuda/std/__fwd/tuple.h
Forward-declaration variable-template traits __is_cuda_std_pair, __is_cuda_std_tuple, and __is_cuda_std_ranges_subrange_v added to enable compile-time identification of CUDA std types.
Tuple-like detection trait rename and use
libcudacxx/include/cuda/std/__tuple_dir/tuple_like.h
Rebases internal tuple-like detection to __tuple_like_ext, updates its specializations for tuple-like types, and rewires __tuple_like/__pair_like to use it.
Constraint machinery rewrite
libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h
Replaces predicate-and-nested-template __tuple_constraints with a consteval-checker-based _TupleConstructorTraits computation and helpers; updates __tuple_like_with_size to use __tuple_like and refreshes comparison derivations.
Tuple class constructor refactoring
libcudacxx/include/cuda/std/__tuple_dir/tuple.h
Adds _Constraints alias and rewrites tuple constructors to use nested _Constraints construction traits for SFINAE and noexcept; expands tuple-like converting overloads across reference categories.
Tuple leaf default constructor and element extraction
libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h
Splits __tuple_impl default ctor into implicit/explicit SFINAE overloads, shifts noexcept to __nothrow_constructible, and uses cuda::std::get on forwarded tuples for element initialization (allocator and non-allocator forms).
Tuple cat return-type update
libcudacxx/include/cuda/std/__tuple_dir/tuple_cat.h
Updates __tuple_cat_return specializations to use __tuple_like_ext for tuple-like detection in return-type computation.
Test support infrastructure
libcudacxx/test/support/copy_move_types.h
Adds a test header providing many probe types modeling constrained/asymmetric copy/move/convert/allocator behaviors, tracing counters for constructor/assignment selection, and implicit-constructibility helpers.
Tuple construction tests
libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/*, libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.traits/trivially_copyable.pass.cpp
Adds multiple test translation units validating tuple construction from pair (const/non-const), tuple-to-tuple conversions (const/non-const copy/move), explicitness/convertibility rules, and traced constructor selection; updates an existing explicit-conversion test and a trivially-copyable expectation.
  • Suggested reviewers:
    • ericniebler
    • alliepiper
    • davebayer

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 18663b2f-23bd-4106-9902-09d7a6c620d4

📥 Commits

Reviewing files that changed from the base of the PR and between 589097d and 93d612c.

📒 Files selected for processing (16)
  • libcudacxx/include/cuda/std/__fwd/pair.h
  • libcudacxx/include/cuda/std/__fwd/subrange.h
  • libcudacxx/include/cuda/std/__fwd/tuple.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_cat.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like_ext.h
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_move_pair.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_const_move.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_non_const_copy.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/non_const_pair.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.traits/trivially_copyable.pass.cpp
  • libcudacxx/test/support/copy_move_types.h
💤 Files with no reviewable changes (1)
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like_ext.h

Comment thread libcudacxx/include/cuda/std/__tuple_dir/tuple.h Outdated
Comment thread libcudacxx/include/cuda/std/__tuple_dir/tuple.h
Comment thread libcudacxx/test/support/copy_move_types.h
Comment thread libcudacxx/test/support/copy_move_types.h
@miscco miscco force-pushed the tupe_constraints_rewrite branch from 93d612c to f46bbc9 Compare May 21, 2026 10:10
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
libcudacxx/include/cuda/std/__fwd/pair.h (1)

43-47: 💤 Low value

suggestion: Consider renaming to __is_cuda_std_pair_v for consistency with __is_tuple_of_iterator_references_v (line 40 of __fwd/tuple.h). The codebase has mixed patterns (__tuple_like_ext lacks _v, but iterator-references trait has it); standardizing on _v for boolean variable-template detection traits would improve uniformity.

libcudacxx/include/cuda/std/__fwd/tuple.h (1)

42-46: 💤 Low value

suggestion: Consider renaming to __is_cuda_std_tuple_v for consistency with __is_tuple_of_iterator_references_v at line 40 in this same file. Both are boolean variable-template detection traits; matching naming conventions within the same header improves readability.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 31a7c568-a91d-424a-942f-65730dfe1952

📥 Commits

Reviewing files that changed from the base of the PR and between 93d612c and f46bbc9.

📒 Files selected for processing (16)
  • libcudacxx/include/cuda/std/__fwd/pair.h
  • libcudacxx/include/cuda/std/__fwd/subrange.h
  • libcudacxx/include/cuda/std/__fwd/tuple.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_cat.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like_ext.h
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_move_pair.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_const_move.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_non_const_copy.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/non_const_pair.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.traits/trivially_copyable.pass.cpp
  • libcudacxx/test/support/copy_move_types.h
💤 Files with no reviewable changes (1)
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like_ext.h

@miscco miscco force-pushed the tupe_constraints_rewrite branch from f46bbc9 to 21aa1e3 Compare May 21, 2026 12:59
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5671e078-4c87-47a1-9dcd-94832367d4ec

📥 Commits

Reviewing files that changed from the base of the PR and between f46bbc9 and 21aa1e3.

📒 Files selected for processing (16)
  • libcudacxx/include/cuda/std/__fwd/pair.h
  • libcudacxx/include/cuda/std/__fwd/subrange.h
  • libcudacxx/include/cuda/std/__fwd/tuple.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_cat.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like_ext.h
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_move_pair.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_const_move.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_non_const_copy.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/non_const_pair.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.traits/trivially_copyable.pass.cpp
  • libcudacxx/test/support/copy_move_types.h
💤 Files with no reviewable changes (1)
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like_ext.h
✅ Files skipped from review due to trivial changes (1)
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp

Comment thread libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h
Comment thread libcudacxx/test/support/copy_move_types.h
@github-actions

This comment has been minimized.

@miscco miscco force-pushed the tupe_constraints_rewrite branch from ce8a059 to f423ab2 Compare May 21, 2026 18:51
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_const_move.pass.cpp (1)

116-131: ⚡ Quick win

suggestion: Lines 116-131 disable these constraint cases for every compiler via #if 0; gate them only for the compiler/version that actually segfaults so other toolchains keep this coverage.

libcudacxx/include/cuda/std/__fwd/subrange.h (1)

56-56: 💤 Low value

suggestion: Naming inconsistency with other detection traits. __is_cuda_std_ranges_subrange_v has a _v suffix, but __is_cuda_std_pair and __is_cuda_std_tuple do not. For internal consistency, either add _v to all three or remove it from this one.

Also applies to: 59-59


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: aff077ac-4ceb-498f-9dbe-7ce4a83c0012

📥 Commits

Reviewing files that changed from the base of the PR and between ce8a059 and f423ab2.

📒 Files selected for processing (16)
  • libcudacxx/include/cuda/std/__fwd/pair.h
  • libcudacxx/include/cuda/std/__fwd/subrange.h
  • libcudacxx/include/cuda/std/__fwd/tuple.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_cat.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like.h
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like_ext.h
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_move_pair.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_const_move.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_non_const_copy.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/non_const_pair.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.traits/trivially_copyable.pass.cpp
  • libcudacxx/test/support/copy_move_types.h
💤 Files with no reviewable changes (1)
  • libcudacxx/include/cuda/std/__tuple_dir/tuple_like_ext.h

@github-actions

This comment has been minimized.

@miscco miscco force-pushed the tupe_constraints_rewrite branch from f423ab2 to a201d6d Compare May 22, 2026 06:39
miscco added 2 commits May 22, 2026 09:50
The standard talks about `Types` and `UTypes`. Using those names makes it easier to follow
@miscco miscco force-pushed the tupe_constraints_rewrite branch from a201d6d to 4ab569e Compare May 22, 2026 07:52
@miscco miscco force-pushed the tupe_constraints_rewrite branch from 4ab569e to 57e3022 Compare May 22, 2026 08:52
@github-actions
Copy link
Copy Markdown
Contributor

😬 CI Workflow Results

🟥 Finished in 3h 56m: Pass: 71%/116 | Total: 5d 05h | Max: 3h 55m | Hits: 41%/2159167

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.

2 participants