atomic_ref<T>
is not convertible to atomic_ref<const T>| Document #: | P3860R1 [Latest] [Status] |
| Date: | 2025-11-03 |
| Project: | Programming Language C++ |
| Audience: |
LEWG, LWG |
| Reply-to: |
Hui Xie <hui.xie1990@gmail.com> Damien Lebrun-Grandié <lebrungrandt@ornl.gov> |
noexcept
specifier.T and
U are similar types” per LWG
feedbackThis paper proposes a converting constructor for
atomic_ref as the resolution for UK
NB Comment GB13-309.
The UK NB Comment GB13-309 pointed out that atomic_ref<T>
is not convertible to atomic_ref<const T>.
[P3323R1] added cv qualifiers to
atomic and
atomic_ref. However, the conversion
constructor of atomic_ref between
different cv qualifiers is overlooked.
Change [atomics.ref.generic.general] as follows:
constexpr explicit atomic_ref(T&);
constexpr atomic_ref(const atomic_ref&) noexcept;
template <class U>
constexpr atomic_ref(const atomic_ref<U>&) noexcept;Add a new entry to [atomics.ref.ops] after paragraph 8:
template <class U>
constexpr atomic_ref(const atomic_ref<U>& ref) noexcept;9 Contraints:
10
Postconditions: *this
references the object referenced by
ref.
Change [atomics.ref.int] as follows:
constexpr explicit atomic_ref(integral-type&);
constexpr atomic_ref(const atomic_ref&) noexcept;
template <class U>
constexpr atomic_ref(const atomic_ref<U>&) noexcept;Change [atomics.ref.float] as follows:
constexpr explicit atomic_ref(floating-point-type&);
constexpr atomic_ref(const atomic_ref&) noexcept;
template <class U>
constexpr atomic_ref(const atomic_ref<U>&) noexcept;Change [atomics.ref.pointer] as follows:
constexpr explicit atomic_ref(pointer-type&);
constexpr atomic_ref(const atomic_ref&) noexcept;
template <class U>
constexpr atomic_ref(const atomic_ref<U>&) noexcept;[P3323R1] is currently being implemented in libc++ and adding the proposed constructor is under way.
[P3323R1] does not seem to mention Feature Test Macro