Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make STL components not dependent on is_trivial(_v) #5202

Merged
merged 7 commits into from
Jan 14, 2025

Conversation

frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Dec 23, 2024

Towards #5137/WG21-P3247R2. IMO most related changes should be done for older modes. libstdc++ is already doing so.

Product code

  • On type requirements of basic_string: There requirements seem to be slightly strengthened, but I don't believe a "character-like type" with a private default constructor can ever be supported.
    • For basic_string_view, it seems that "character-like type" with a private default constructor can be supported. I'm not sure whether it should be changed.
  • On _Can_memcpy_val: Trivial default-constructibility is not actually requried, so I just relax the condition to is_trivially_copyable_v.
  • On _Uninitialized_copy_multidimensional(_al): Like above, but the dispatching condition should be more precise.
  • On internal hashing functions and _Circular_buffer: static_assert doesn't seem necessary as the involved types are either scalar or implementation-controlled, but the checks seem desired to avoid regression.
  • On _Unaligned_load: The function template is used and instantiated only once, so I think it's better to inline it into the caller.

Test code

  • Given "is_trivially_copyable_v & is_trivially_default_constructible_v" is slight stronger than "is_trivial_v", I decide to use the former style thoroughly except when is_trivial(_v) themselves are tested.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner December 23, 2024 04:04
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Jan 4, 2025
@StephanTLavavej StephanTLavavej self-assigned this Jan 4, 2025
stl/inc/type_traits Outdated Show resolved Hide resolved
stl/inc/xstring Outdated Show resolved Hide resolved
stl/inc/xstring Show resolved Hide resolved
stl/inc/__msvc_string_view.hpp Outdated Show resolved Hide resolved
tests/std/tests/P0009R18_mdspan_layout_left/test.cpp Outdated Show resolved Hide resolved
@StephanTLavavej
Copy link
Member

Thanks!

For basic_string_view, it seems that "character-like type" with a private default constructor can be supported. I'm not sure whether it should be changed.

That would be an abomination, let's not make any attempt to do so.

@StephanTLavavej StephanTLavavej removed their assignment Jan 8, 2025
@StephanTLavavej StephanTLavavej self-assigned this Jan 13, 2025
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit a9861c9 into microsoft:main Jan 14, 2025
39 checks passed
@StephanTLavavej
Copy link
Member

Thanks for the non-trivial improvement! 🤪 😹 🐱

@frederick-vs-ja frederick-vs-ja deleted the pre-p3247r2 branch January 14, 2025 13:49
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
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants