Skip to content

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

Merged
miscco merged 73 commits into
NVIDIA:mainfrom
miscco:tupe_constraints_rewrite
Jun 2, 2026
Merged

[libcu++] Implement tuple-like constructors for tuple#9059
miscco merged 73 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

Walkthrough

Refactors CUDA libcudacxx tuple construction by introducing consteval-based constraint checkers and rebasing tuple-like trait detection, updates tuple/leaf/tuple_cat implementations, adds forward-declaration type traits, expands test coverage with pair/tuple conversion tests, and cleans up test directives.

Changes

Tuple construction and constraint machinery

Layer / File(s) Summary
Forward-declaration type-detection traits
libcudacxx/include/cuda/std/__fwd/pair.h, libcudacxx/include/cuda/std/__fwd/subrange.h, libcudacxx/include/cuda/std/__fwd/tuple.h
Adds __is_cuda_std_pair, __is_cuda_std_ranges_subrange_v, and __is_cuda_std_tuple variable templates for compile-time type detection of CUDA std types.
Tuple-like trait rebasing: __tuple_like_ext
libcudacxx/include/cuda/std/__tuple_dir/tuple_like.h
Renames internal __tuple_like_impl to __tuple_like_ext and updates __tuple_like concept and __pair_like requires-clause to reference the new trait.
Constraint machinery: consteval checkers and trait structures
libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h
Replaces predicate scaffolding with consteval construction selectors, comparison traits, and sentinel types; introduces __select_constructor enum, construction feasibility functions, and tuple-like/comparison detection helpers.
Tuple class constructors and comparison operators
libcudacxx/include/cuda/std/__tuple_dir/tuple.h
Refactors default, allocator-arg, variadic copy/move, and tuple-like converting constructors to use checker-returned traits for enablement and noexcept; updates comparison operators; adds tuple common_reference and common_type specializations.
Tuple leaf implementation and tuple-like constructor tagging
libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h
Adds __tuple_like_constructor_tag for tag-dispatch, defaults leaf default constructor, and implements tag-dispatched tuple-like constructors; updates variadic constructor noexcept to fold over is_nothrow_constructible_v.
Helper trait updates: common_reference and deprecation suppression
libcudacxx/include/cuda/std/__type_traits/common_reference.h, libcudacxx/include/cuda/std/__type_traits/is_implicitly_default_constructible.h
Extends basic_common_reference signature with trailing void parameter; wraps is_implicitly_default_constructible trait with deprecation suppression macros.
Tuple-cat and make_tuple_types dependent updates
libcudacxx/include/cuda/std/__tuple_dir/tuple_cat.h, libcudacxx/include/cuda/std/__tuple_dir/make_tuple_types.h
Updates tuple_cat to use __tuple_like_ext for type detection; adds host-stdlib-guarded __make_tuple_types_flat specializations for ::std::array and ::std::complex.
Test support: copy/move probe types and tracing infrastructure
libcudacxx/test/support/copy_move_types.h
Adds comprehensive test support header with copy/move construction probes (MutableCopy, ConstCopy, MutableMove, ConstMove), convertibility wrappers (ConvertibleFrom, ExplicitConstructibleFrom), tracing types (TracedCopyMove, TracedAssignment), tuple-reference conversion probes, and ImplicitlyConstructible detection; includes allocator-aware specializations.
Pair-to-tuple conversion tests
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/non_const_pair.pass.cpp
Adds tests validating tuple construction from const and non-const pair rvalues with compile-time constraint checks (arity, constructibility, explicitness) and runtime tracing of constructor paths.
Tuple-to-tuple conversion tests
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
Adds tests for const-rvalue and lvalue-reference tuple conversions verifying implicit/explicit rules, element-wise constructibility, arity matching, and traced constructor invocation; includes GCC-version-gated and MSVC-excluded scenarios.
Test directive cleanup and minor fixes
libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp, libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/*, libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.helper/*, libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.traits/trivially_copyable.pass.cpp, libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp
Removes or narrows UNSUPPORTED/XFAIL directives, updates PR31384 with explicit tuple returns and host-vs-device expectations, adds [[maybe_unused]] annotation, and adds explicit defaulted copy constructor to NonTriviallyCopyAble.

Possibly related PRs

  • NVIDIA/cccl#9126: Refactors internal tuple/pair-like detection updating __pair_like to use __tuple_like and removing related scaffolding; foundational plumbing for this PR's constraint machinery.

Suggested labels

libcu++

Suggested reviewers

  • ericniebler
  • elstehle

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 Outdated
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 3 times, most recently from 4ab569e to 57e3022 Compare May 22, 2026 08:52
@miscco miscco force-pushed the tupe_constraints_rewrite branch from 619692c to 40ce652 Compare June 1, 2026 08:03
@miscco miscco force-pushed the tupe_constraints_rewrite branch 5 times, most recently from 2f21ed9 to 5fd347c Compare June 1, 2026 10:42
@miscco miscco force-pushed the tupe_constraints_rewrite branch from 5fd347c to 7a193ac Compare June 1, 2026 11:51
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

🥳 CI Workflow Results

🟩 Finished in 3h 20m: Pass: 100%/116 | Total: 5d 04h | Max: 3h 20m | Hits: 38%/2098608

See results here.

@miscco miscco merged commit 9a8f7f6 into NVIDIA:main Jun 2, 2026
136 of 137 checks passed
@miscco miscco deleted the tupe_constraints_rewrite branch June 2, 2026 10:27
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants