atomic_ref<T>
is not convertible to
atomic_ref<const T>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 32.5.7.1 General [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 32.5.7.2 Operations [atomics.ref.ops] after paragraph 8:
template <class U>
constexpr atomic_ref(const atomic_ref<U>& ref) noexcept;9 Contraints:
(9.1)
T and
U are similar types ([conv.qual]), and
(9.2)
is_convertible_v<U*, T*>
is true
10 Postconditions:
*this references the object
referenced by ref.
Change 32.5.7.3 Specializations for integral types [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 32.5.7.4 Specializations for floating-point types [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 32.5.7.5 Specialization for pointers [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