Skip to content

<compare>: fix constructibility of ordering types#5911

Open
vmichal wants to merge 13 commits intomicrosoft:mainfrom
vmichal:make-ordering-types-not-constructible
Open

<compare>: fix constructibility of ordering types#5911
vmichal wants to merge 13 commits intomicrosoft:mainfrom
vmichal:make-ordering-types-not-constructible

Conversation

@vmichal
Copy link
Contributor

@vmichal vmichal commented Nov 26, 2025

Touches std::strong_ordering, std::weak_ordering, std::partial_ordering.

Fixes #5689.

@vmichal vmichal requested a review from a team as a code owner November 26, 2025 01:44
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Nov 26, 2025
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Nov 26, 2025
@StephanTLavavej StephanTLavavej changed the title <compare>: fix constructibility of ordering types, prevent structured bindings <compare>: fix constructibility of ordering types, prevent structured bindings Nov 29, 2025
@AlexGuteniev

This comment was marked as resolved.

@StephanTLavavej StephanTLavavej changed the title <compare>: fix constructibility of ordering types, prevent structured bindings <compare>: fix constructibility of ordering types Mar 20, 2026
Record the bug title.
`typename` => `class` for consistency.
Drop todo about structured bindings.
Comment why the deleted ctors need to be constexpr.
We conventionally avoid abbreviated function templates.
We don't need a secret tag; `template <int>` suffices because it can't be deduced.
@StephanTLavavej
Copy link
Member

Thanks! 😻 I pushed the following changes:

  • Cleanup test.
    • Record the bug title.
    • typename => class for consistency.
    • Drop todo about structured bindings.
  • Add test coverage for overload resolution.
  • Drop attempt to prevent structured bindings.
  • Simplify the deleted constructors.
    • Comment why the deleted ctors need to be constexpr.
    • We conventionally avoid abbreviated function templates.
    • We don't need a secret tag; template <int> suffices because it can't be deduced.

This appears to be ABI-safe: https://godbolt.org/z/MhqeoerKK

@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews Mar 20, 2026
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Mar 21, 2026
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo. Please notify me if any further changes are pushed, otherwise no action is required.

StephanTLavavej added a commit to StephanTLavavej/STL that referenced this pull request Mar 21, 2026
StephanTLavavej added a commit to StephanTLavavej/STL that referenced this pull request Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Something can be improved

Projects

Status: Merging

Development

Successfully merging this pull request may close these issues.

<compare>: ordering types are default constructible and constructible from integer types

4 participants