Skip to content

[libcu++] Implement tuple-like constructors for pair#9543

Open
miscco wants to merge 9 commits into
NVIDIA:mainfrom
miscco:tuple_like_pair
Open

[libcu++] Implement tuple-like constructors for pair#9543
miscco wants to merge 9 commits into
NVIDIA:mainfrom
miscco:tuple_like_pair

Conversation

@miscco

@miscco miscco commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

This implements the pair constructors for tuple-like types and slightly cleans up the constraints type

@miscco miscco requested a review from a team as a code owner June 22, 2026 13:29
@miscco miscco requested a review from griwes June 22, 2026 13:29
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jun 22, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jun 22, 2026
@miscco miscco force-pushed the tuple_like_pair branch from d7633c3 to a52e267 Compare June 22, 2026 13:32
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

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

Refactors cuda::std::pair constructor SFINAE from __pair_constraints-based members to __select_constructor traits (__tuple_select_default_constructible, __can_construct_implicitly/__can_construct_explicitly) and adds __pair_select_pair_like_constructible_v for pair-like conversions. Updates existing pair and tuple-like tests with const qualifiers, modern trait syntax, and constexpr enforcement. Adds six new conformance tests covering const, move, non-const copy, and pair-like construction paths.

Changes

cuda::std::pair constructor refactor and test suite update

Layer / File(s) Summary
pair constraint machinery and pair-like selector
libcudacxx/include/cuda/std/__utility/pair.h, libcudacxx/include/cuda/std/__fwd/get.h
Adds tuple-related forward-declaration includes and ADL-get infrastructure macro. Introduces __pair_select_pair_like_constructible consteval helper and inline variable template. Removes element-wise boolean members from __pair_constraints. Refactors __pair_base default constructors (both general and true-specialization) to use __tuple_select_default_constructible with __can_construct_implicitly/__can_construct_explicitly.
cuda::std::pair public constructor set rework
libcudacxx/include/cuda/std/__utility/pair.h
Rewrites all public cuda::std::pair constructors—default, element-wise, pair-to-pair converting, and pair-like converting (via __adl_get)—to use __select_constructor traits and __pair_select_pair_like_constructible_v instead of __pair_constructible/__pair_constraints alias-based SFINAE.
Updates to existing pair and tuple-like tests
libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_tuple_like.pass.cpp, const_move_tuple_like.pass.cpp, move_tuple_like.pass.cpp, non_const_tuple_like.pass.cpp, libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_copy.cpp, convert_move.cpp
Adds const qualifiers to tuple-like test variables. Adds missing standard library includes (<complex>, <tuple>) under host-build guards. Updates is_constructible<...>::value to is_constructible_v<...>. Introduces constexpr bool test() functions, expands assertions for ExplicitT/ImplicitT, and adds static_assert(test()) enforcement.
New pair-like construction conformance tests
libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_pair_like.pass.cpp, const_move_pair_like.pass.cpp, move_pair_like.pass.cpp, non_const_pair_like.pass.cpp
Adds tests for implicit/explicit cuda::std::pair construction from array, tuple, and complex pair-like sources across const, move, and non-const copy paths, with TracedCopyMove dispatch assertions and host-stdlib conditional guards.
New convert_const_move and convert_non_const_copy tests
libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_const_move.cpp, convert_non_const_copy.cpp
Adds test_pair_rv/test_pair_non_const templates, DPair derived wrapper, ExplicitT/ImplicitT archetypes, and compile-time constructibility/convertibility coverage including unique_ptr base/derived transfer, reference-dangling negative cases, and static_assert(test()) enforcement.

Suggested reviewers

  • ericniebler
  • davebayer

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

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 4

🧹 Nitpick comments (2)
libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_pair_like.pass.cpp (1)

78-85: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

suggestion: use std::complex<double> in this host-only __cpp_lib_tuple_like branch. Line 81 currently uses cuda::std::complex<double>, so this branch re-tests the cuda path instead of the host std tuple-like path.

libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/move_pair_like.pass.cpp (1)

30-87: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

suggestion: Consider adding a TEST_FUNC bool test() wrapper and calling test() from main() for consistency with other pair tests (e.g., non_const_pair_like.pass.cpp). If MoveOnly prevents constexpr, document that limitation. Otherwise, add static_assert(test()) to catch issues at compile-time.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8383ce8e-2917-4a37-a103-44b8699486ad

📥 Commits

Reviewing files that changed from the base of the PR and between 5ba76c7 and d7633c3.

📒 Files selected for processing (13)
  • libcudacxx/include/cuda/std/__utility/pair.h
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_tuple_like.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_first_const_second_cxx03.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_move_pair_like.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_pair_like.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_const_move.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_copy.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_move.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/move_pair_like.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/non_const_pair_like.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/not_constexpr_cxx11.fail.cpp
💤 Files with no reviewable changes (3)
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/not_constexpr_cxx11.fail.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_first_const_second_cxx03.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp

Comment thread libcudacxx/include/cuda/std/__utility/pair.h
Comment thread libcudacxx/include/cuda/std/__utility/pair.h
Comment thread libcudacxx/include/cuda/std/__utility/pair.h
Comment on lines +159 to +161
// test_pair_non_const<ConvertingType&&, int>();
// test_pair_non_const<ConvertingType const&, int>();
// test_pair_non_const<ConvertingType const&&, int>();

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 can't these be tested? We don't care about dangling references in test code no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe the issue is that we should dissallow cnostruction from temporaries, but that requires relatively recent compilers

https://eel.is/c++draft/pairs.pair#13

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2d1a9fc1-c175-4d4c-83e8-9dd2b65236b6

📥 Commits

Reviewing files that changed from the base of the PR and between d7633c3 and a52e267.

📒 Files selected for processing (13)
  • libcudacxx/include/cuda/std/__utility/pair.h
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_tuple_like.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_first_const_second_cxx03.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_move_pair_like.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_pair_like.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_const_move.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_copy.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_move.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/move_pair_like.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/non_const_pair_like.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/not_constexpr_cxx11.fail.cpp
💤 Files with no reviewable changes (3)
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_first_const_second_cxx03.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/not_constexpr_cxx11.fail.cpp
✅ Files skipped from review due to trivial changes (1)
  • libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_tuple_like.pass.cpp
🚧 Files skipped from review as they are similar to previous changes (4)
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_copy.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_move.cpp
  • libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpp
  • libcudacxx/include/cuda/std/__utility/pair.h

@miscco miscco force-pushed the tuple_like_pair branch from 7ff1f03 to 838c678 Compare June 22, 2026 14:04

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4d1f1e65-102b-4b33-991a-e3084cc9b780

📥 Commits

Reviewing files that changed from the base of the PR and between 838c678 and 4876b4a.

📒 Files selected for processing (1)
  • libcudacxx/include/cuda/std/__fwd/get.h

Comment thread libcudacxx/include/cuda/std/__fwd/get.h Outdated
@miscco miscco force-pushed the tuple_like_pair branch from 4876b4a to ae513cf Compare June 22, 2026 17:02
@github-actions

This comment has been minimized.

@miscco miscco enabled auto-merge (squash) June 23, 2026 07:06
@miscco miscco force-pushed the tuple_like_pair branch from ae513cf to 41d6eef Compare June 23, 2026 08:51
Comment thread libcudacxx/include/cuda/std/__utility/pair.h Outdated
Comment thread libcudacxx/include/cuda/std/__utility/pair.h
Comment thread libcudacxx/include/cuda/std/__utility/pair.h Outdated
Comment thread libcudacxx/include/cuda/std/__utility/pair.h Outdated
@github-actions

This comment has been minimized.

@miscco miscco force-pushed the tuple_like_pair branch from f41cc03 to 9901376 Compare June 23, 2026 16:19
@github-actions

Copy link
Copy Markdown
Contributor

😬 CI Workflow Results

🟥 Finished in 4h 03m: Pass: 88%/118 | Total: 1d 18h | Max: 1h 03m | Hits: 99%/341045

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.

3 participants