Created on 2023-03-27.00:00:00 last changed 17 months ago
Proposed resolution:
This wording is relative to n4944.
Add the following bullet before [unique.ptr.single.observers] paragraph 1:
constexpr add_lvalue_reference_t<T> operator*() const noexcept(noexcept(*declval<pointer>()));
-1- Preconditions:
get() != nullptr
.-2-
ReturnsEffects: Equivalent to:return
*get();
.
Add the following bullet before [unique.ptr.runtime.observers] paragraph 1:
constexpr T& operator[](size_t i) const;
-1- Preconditions:
get() != nullptr
.i
< the number of elements in the array to which the stored pointer points-2-
ReturnsEffects: Equivalent to:return
get()[i];
.
[ 2023-04-03; Jonathan provides new wording as requested by LWG ]
[ 2023-03-28; Reflector poll ]
Set priority to 3 after reflector poll.
"It would be nice to Mandate !reference_converts_from_temporary_v<add_lvalue_reference_t<T>, decltype(*get())>
."
"noexcept-specifier isn't quite right, conversion from *get()
to T&
can throw."
This wording is relative to n4944.
Add the following bullet before [unique.ptr.single.observers] paragraph 1:
constexpr add_lvalue_reference_t<T> operator*() const noexcept(noexcept(*declval<pointer>()));
-?- Mandates:
*get()
is a valid expression that is convertible toadd_lvalue_reference_t<T>
.-1- Preconditions:
get() != nullptr
.-2- Returns:
*get()
.
Add the following bullet before [unique.ptr.runtime.observers] paragraph 1:
constexpr T& operator[](size_t i) const;
-?- Mandates:
get()[i]
is a valid expression that is convertible toT&
.-1- Preconditions:
i
< the number of elements in the array to which the stored pointer points.-2- Returns:
get()[i]
.
The return type of std::unique_ptr<T>::operator*
is
std::add_lvalue_reference_t<T>
,
but there is no mandate stating that *get()
is convertible to that type.
There also does not appear to be a mandate that *get()
is a valid expression;
dereferenceability is not part of the Cpp17NullablePointer requirements.
A similar issue appears to exist for std::unique_ptr<T[]>::operator[]
.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-06-01 14:48:40 | admin | set | messages: + msg13612 |
2023-04-03 12:43:16 | admin | set | messages: + msg13509 |
2023-03-27 14:46:04 | admin | set | messages: + msg13498 |
2023-03-27 00:00:00 | admin | create |