Skip to content

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

Open
frederick-vs-ja wants to merge 8 commits intomicrosoft:mainfrom
frederick-vs-ja:p3860r1
Open

Implement P3860R1 Make atomic_ref<T> Convertible To atomic_ref<const T>#5846
frederick-vs-ja wants to merge 8 commits intomicrosoft:mainfrom
frederick-vs-ja:p3860r1

Conversation

@frederick-vs-ja
Copy link
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
@StephanTLavavej
Copy link
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
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

Status: Ready To Merge

Development

Successfully merging this pull request may close these issues.

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

2 participants