Implement P3860R1 Make atomic_ref<T> Convertible To atomic_ref<const T>
#5846
+233
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #5838.
Notes:
constexpris intentionally not added because it should belong to P3309R3 "constexpratomicAndatomic_ref". The new constructor should be marked_CONSTEXPR26in a future PR.explicit atomic_ref(_Ty&&) = delete;overload to disallow bogus explicit construction ofatomic_ref<const T>fromatomic_ref<volatile T>oratomic_ref<const volatile T>. Such construction is currently unfortunately well-formed because of theoperator Tconversion function. I've mailed LWG Chair to file an LWG issue for this. Edit: The issue is now LWG-4472.is_convertible_v<_Uty (*)[], _Ty (*)[]>, which is consistent with pre-existing detections inunique_ptr,shared_ptr,span,mdspan, andranges::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.