Created on 2016-08-04.00:00:00 last changed 13 months ago
Proposed resolution:
This wording is relative to N4892.
[Drafting note: since this issue is all about consistency, optional's pointer-like operators are additionally included.]
Edit [unique.ptr.single.general], class template unique_ptr synopsis, as indicated:
namespace std {
template<class T, class D = default_delete<T>> class unique_ptr {
public:
[…]
// [unique.ptr.single.observers], observers
add_lvalue_reference_t<T> operator*() const noexcept(see below);
[…]
};
}
Edit [unique.ptr.single.observers] as indicated:
add_lvalue_reference_t<T> operator*() const noexcept(noexcept(*declval<pointer>()));-1- Preconditions: get() != nullptr.
-2- Returns: *get().
Edit [optional.optional.general], class template optional synopsis, as indicated:
namespace std {
template<class T>
class optional {
public:
[…]
// [optional.observe], observers
constexpr const T* operator->() const noexcept;
constexpr T* operator->() noexcept;
constexpr const T& operator*() const & noexcept;
constexpr T& operator*() & noexcept;
constexpr T&& operator*() && noexcept;
constexpr const T&& operator*() const && noexcept;
[…]
};
}
Edit [optional.observe] as indicated:
constexpr const T* operator->() const noexcept; constexpr T* operator->() noexcept;-1- Preconditions: *this contains a value.
-2- Returns: val.-3- Throws: Nothing.-4- Remarks: These functions are constexpr functions.constexpr const T& operator*() const & noexcept; constexpr T& operator*() & noexcept;-5- Preconditions: *this contains a value.
-6- Returns: *val.-7- Throws: Nothing.-8- Remarks: These functions are constexpr functions.constexpr T&& operator*() && noexcept; constexpr const T&& operator*() const && noexcept;-9- Preconditions: *this contains a value.
-10- Effects: Equivalent to: return std::move(*val);
[ 2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting → WP. ]
[ 2021-06-23; Reflector poll ]
Set status to Tentatively Ready after seven votes in favour during reflector poll.
[ 2021-06-19 Tim updates wording ]
[ LEWG Kona 2017 ]
->Open: Believe these should be noexcept for consistency. We like these. We agree with the proposed resolution. operator->() already has noexcept.
Also adds optional::operator*
Alisdair points out that fancy pointers might intentionally throw from operator*, and we don't want to prohibit that.
Go forward with conditional noexcept(noexcept(*decltype())).
Previous resolution [SUPERSEDED]:
This wording is relative to N4606.
[Drafting note: since this issue is all about consistency, optional's pointer-like operators are additionally included.]
In [unique.ptr.single] synopsis, edit as follows:
add_lvalue_reference_t<T> operator*() const noexcept;Before [unique.ptr.single.observers]/1, edit as follows:
add_lvalue_reference_t<T> operator*() const noexcept;In [optional.optional] synopsis, edit as follows:
constexpr T const *operator->() const noexcept; constexpr T *operator->() noexcept; constexpr T const &operator*() const & noexcept; constexpr T &operator*() & noexcept; constexpr T &&operator*() && noexcept; constexpr const T &&operator*() const && noexcept;Before [optional.object.observe]/1, edit as follows:
constexpr T const* operator->() const noexcept; constexpr T* operator->() noexcept;Before [optional.object.observe]/5, edit as follows:
constexpr T const& operator*() const & noexcept; constexpr T& operator*() & noexcept;Before [optional.object.observe]/9, edit as follows:
constexpr T&& operator*() && noexcept; constexpr const T&& operator*() const && noexcept;
[ 2016-08-05 Chicago ]
Ville provides an initial proposed wording.
[ 2016-08 — Chicago ]
Thurs PM: P3, and status to 'LEWG'
See LWG 2337. Since we aren't removing noexcept from shared_ptr's operator*, we should consider adding noexcept to unique_ptr's operator*.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2021-10-14 09:56:08 | admin | set | messages: + msg12109 |
2021-10-14 09:56:08 | admin | set | status: voting -> wp |
2021-09-29 12:57:28 | admin | set | status: ready -> voting |
2021-06-23 14:16:45 | admin | set | messages: + msg11951 |
2021-06-23 14:16:45 | admin | set | status: open -> ready |
2021-06-19 18:11:20 | admin | set | messages: + msg11945 |
2018-06-22 06:38:21 | admin | set | messages: + msg9977 |
2018-06-22 06:38:21 | admin | set | status: lewg -> open |
2016-08-05 17:22:18 | admin | set | messages: + msg8427 |
2016-08-05 17:22:18 | admin | set | messages: + msg8426 |
2016-08-05 03:58:49 | admin | set | messages: + msg8424 |
2016-08-05 03:58:49 | admin | set | status: new -> lewg |
2016-08-04 00:00:00 | admin | create |