Skip to content

[libcu++] Improve is_nothrow_meow traits - #10991

Open
davebayer wants to merge 1 commit into
NVIDIA:mainfrom
davebayer:improve_is_nothrow_xxx
Open

[libcu++] Improve is_nothrow_meow traits#10991
davebayer wants to merge 1 commit into
NVIDIA:mainfrom
davebayer:improve_is_nothrow_xxx

Conversation

@davebayer

Copy link
Copy Markdown
Contributor

This PR moves is_nothrow_meow builtins directly to the files and reduces the number of type instantiations.

@davebayer
davebayer requested a review from a team as a code owner August 25, 2026 09:11
@davebayer
davebayer requested a review from griwes August 25, 2026 09:11
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Aug 25, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Aug 25, 2026
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Improvements
    • Improved compiler compatibility and consistency for nothrow type traits.
    • Updated nothrow assignability, constructibility, and destructibility checks across supported compiler configurations.
    • Preserved handling for arrays, references, conversions, and other supported type scenarios.
    • Streamlined trait and variable-template evaluation for more direct, consistent results.

Walkthrough

The pull request relocates nothrow builtin detection into individual trait headers. It rewrites fallback assignability, constructibility, and destructibility evaluation with variable templates. Derived nothrow traits now use bool_constant and direct _v trait expressions.

Changes

Nothrow type traits

Layer / File(s) Summary
Builtin routing
libcudacxx/include/cuda/std/__cccl/builtin.h, libcudacxx/include/cuda/std/__type_traits/is_nothrow_*.h
Shared nothrow builtin wrapper macros were removed. Compiler-specific builtin definitions were added to the assignable, constructible, and destructible trait headers. Builtin-backed traits now use bool_constant.
Fallback evaluation
libcudacxx/include/cuda/std/__type_traits/is_nothrow_assignable.h, libcudacxx/include/cuda/std/__type_traits/is_nothrow_constructible.h, libcudacxx/include/cuda/std/__type_traits/is_nothrow_destructible.h
Fallback checks now use variable-template helpers. Assignability and destruction evaluate noexcept only for valid operations. Constructor, conversion, array, and reference cases remain specialized.
Derived trait forwarding
libcudacxx/include/cuda/std/__type_traits/is_nothrow_copy_assignable.h, libcudacxx/include/cuda/std/__type_traits/is_nothrow_copy_constructible.h, libcudacxx/include/cuda/std/__type_traits/is_nothrow_default_constructible.h, libcudacxx/include/cuda/std/__type_traits/is_nothrow_move_assignable.h, libcudacxx/include/cuda/std/__type_traits/is_nothrow_move_constructible.h
Copy, move, and default nothrow traits now derive from bool_constant and directly use the corresponding _v trait expressions.

Suggested reviewers: griwes

Merge Risk: ⚪ Minimal · up to f23c6

This change only relocates and simplifies nothrow trait builtins; the remaining concern is limited to preprocessor comment consistency, with no actionable merge-blocking risk beyond normal review.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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.

🧹 Nitpick comments (1)
libcudacxx/include/cuda/std/__type_traits/is_nothrow_assignable.h (1)

30-32: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

suggestion: Repeat the complete originating #if condition in each annotated #else and #endif comment.

  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_assignable.h#L30-L32: Include the MSVC and NVRTC clauses in the #endif comment.
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_assignable.h#L36-L46: Repeat the complete defined(...) && !defined(...) condition in the #else comment.
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_constructible.h#L30-L32: Include the MSVC and NVRTC clauses in the #endif comment.
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_destructible.h#L33-L35: Include the MSVC and NVRTC clauses in the #endif comment.
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_destructible.h#L41-L50: Repeat the complete defined(...) && !defined(...) condition in the #else comment.

Based on learnings, annotated preprocessor comments must repeat the exact corresponding condition text.

Source: Learnings


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f455d543-2a82-46f2-ac06-9f8a6c1cd5a5

📥 Commits

Reviewing files that changed from the base of the PR and between 8950ec5 and f23c6dd.

📒 Files selected for processing (9)
  • libcudacxx/include/cuda/std/__cccl/builtin.h
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_assignable.h
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_constructible.h
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_copy_assignable.h
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_copy_constructible.h
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_default_constructible.h
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_destructible.h
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_move_assignable.h
  • libcudacxx/include/cuda/std/__type_traits/is_nothrow_move_constructible.h
💤 Files with no reviewable changes (1)
  • libcudacxx/include/cuda/std/__cccl/builtin.h

Included review availability: Your plan provides up to 12 included reviews per hour; 9 remain after this review.

struct __cccl_is_nothrow_assignable<false, _Tp, _Arg> : public false_type
{};
template <class _Tp, class _Arg, bool _IsAssignable = is_assignable_v<_Tp, _Arg>>
inline constexpr bool __cccl_is_nothrow_assignable_v = false;

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 extra bool? Can't we just define this as is_nothrow_assignable_v?

template <bool, class _Tp, class... _Args>
inline constexpr bool __cccl_is_nothrow_constructible = false;
template <bool _IsConstructible, class _Tp, class... _Args>
inline constexpr bool __cccl_is_nothrow_constructible_v = false;

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.

Same here, let's just define this as is_nothrow_constructible_v directly

inline constexpr bool is_nothrow_copy_assignable_v = _CCCL_BUILTIN_IS_NOTHROW_ASSIGNABLE(
add_lvalue_reference_t<_Tp>, add_lvalue_reference_t<typename add_const<_Tp>::type>);
inline constexpr bool is_nothrow_copy_assignable_v =
_CCCL_BUILTIN_IS_NOTHROW_ASSIGNABLE(add_lvalue_reference_t<_Tp>, add_lvalue_reference_t<add_const_t<_Tp>>);

#else

template <class _Tp>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_nothrow_copy_assignable

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.

Question: can we just define this as a using decl a la

using is_nothrow_copy_assignable = is_nothrow_assignable<add_lvalue_reference_t<_Tp>, add_lvalue_reference_t<add_const_t<_Tp>>>;

? Is it required to be a distinct type? Maybe @miscco would know this as well

@davebayer davebayer Aug 25, 2026

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.

No, The standard requires this to be a separate type

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.

I dont think it needs to be a separate type

That said this would definitely prevent people from specializing it. Given that its almost never used at all internally I would keep it as is

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.

That said this would definitely prevent people from specializing it.

Specializing it is expressly disallowed by the standard though.

@github-actions

Copy link
Copy Markdown
Contributor

😬 CI Workflow Results

🟥 Finished in 4h 26m: Pass: 88%/99 | Total: 5d 02h | Max: 4h 26m | Hits: 8%/257247

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