Skip to content

Implement P3860R1 Make atomic_ref<T> Convertible To atomic_ref<const T>#5846

Merged
StephanTLavavej merged 8 commits into
microsoft:mainfrom
frederick-vs-ja:p3860r1
Feb 11, 2026
Merged

Implement P3860R1 Make atomic_ref<T> Convertible To atomic_ref<const T>#5846
StephanTLavavej merged 8 commits into
microsoft:mainfrom
frederick-vs-ja:p3860r1

Conversation

@frederick-vs-ja
Copy link
Copy Markdown
Contributor

@frederick-vs-ja frederick-vs-ja commented Nov 12, 2025

Fixes #5838.

Notes:

  • constexpr is intentionally not added because it should belong to P3309R3 "constexpr atomic And atomic_ref". The new constructor should be marked _CONSTEXPR26 in a future PR.
  • This PR also adds an explicit atomic_ref(_Ty&&) = delete; overload to disallow bogus explicit construction of atomic_ref<const T> from atomic_ref<volatile T> or atomic_ref<const volatile T>. Such construction is currently unfortunately well-formed because of the operator T conversion function. I've mailed LWG Chair to file an LWG issue for this. Edit: The issue is now LWG-4472.
  • Convertibility detection in the new constraints is implemented with is_convertible_v<_Uty (*)[], _Ty (*)[]>, which is consistent with pre-existing detections in unique_ptr, shared_ptr, span, mdspan, and ranges::subrange. Conversions related to array of unknown bound types are not yet tested because MSVC and EDG (and even GCC) seem to be buggy for the the changes in WG21-P0388R4.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner November 12, 2025 01:27
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Nov 12, 2025
@StephanTLavavej StephanTLavavej added cxx20 C++20 feature defect report Applied retroactively labels Nov 12, 2025
Comment thread tests/std/tests/P0019R8_atomic_ref/test.cpp Outdated
Comment thread tests/std/tests/P0019R8_atomic_ref/test.cpp
@StephanTLavavej
Copy link
Copy Markdown
Member

Thanks! I pushed a trivial rename (partially pre-existing, I believe) and additional test coverage from volatile T to const volatile T, please meow if that's not cromulent for some reason.

@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews Feb 7, 2026
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Feb 9, 2026
@StephanTLavavej
Copy link
Copy Markdown
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 StephanTLavavej merged commit 0c32303 into microsoft:main Feb 11, 2026
45 checks passed
@github-project-automation github-project-automation Bot moved this from Merging to Done in STL Code Reviews Feb 11, 2026
@StephanTLavavej
Copy link
Copy Markdown
Member

☢️ 🔀 ☢️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cxx20 C++20 feature defect report Applied retroactively

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P3860R1 Make atomic_ref<T> Convertible To atomic_ref<const T>

2 participants