-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
LWGLibrary Working Group issueLibrary Working Group issuefixedSomething works now, yay!Something works now, yay!good first issueGood for newcomersGood for newcomers
Description
LWG-2762 asks for unique_ptr and optional indirection operators to be noexcept
unique_ptr is already noexcept. It is marked as /* strengthened */ as this noexcept was not previously require by the Standard.
Note that LWG requires conditional noexcept(noexcept(*declval<pointer>()))
According to [unique.ptr.single.general]/3, unique_ptr<T, D> may obtain fancy pointer as underlying pointer type via remove_reference_t<D>::pointer.
Line 3210 in dc888f7
| _NODISCARD add_lvalue_reference_t<_Ty> operator*() const noexcept /* strengthened */ { |
So the fix is to change noexcept to conditional, and remove /* strengthened */ comment.
optional misses noexcept, it should be added:
Lines 345 to 381 in dc888f7
| _NODISCARD constexpr const _Ty* operator->() const { | |
| #if _CONTAINER_DEBUG_LEVEL > 0 | |
| _STL_VERIFY(this->_Has_value, "Cannot access value of empty optional"); | |
| #endif // _CONTAINER_DEBUG_LEVEL > 0 | |
| return _STD addressof(this->_Value); | |
| } | |
| _NODISCARD constexpr _Ty* operator->() { | |
| #if _CONTAINER_DEBUG_LEVEL > 0 | |
| _STL_VERIFY(this->_Has_value, "Cannot access value of empty optional"); | |
| #endif // _CONTAINER_DEBUG_LEVEL > 0 | |
| return _STD addressof(this->_Value); | |
| } | |
| _NODISCARD constexpr const _Ty& operator*() const& { | |
| #if _CONTAINER_DEBUG_LEVEL > 0 | |
| _STL_VERIFY(this->_Has_value, "Cannot access value of empty optional"); | |
| #endif // _CONTAINER_DEBUG_LEVEL > 0 | |
| return this->_Value; | |
| } | |
| _NODISCARD constexpr _Ty& operator*() & { | |
| #if _CONTAINER_DEBUG_LEVEL > 0 | |
| _STL_VERIFY(this->_Has_value, "Cannot access value of empty optional"); | |
| #endif // _CONTAINER_DEBUG_LEVEL > 0 | |
| return this->_Value; | |
| } | |
| _NODISCARD constexpr _Ty&& operator*() && { | |
| #if _CONTAINER_DEBUG_LEVEL > 0 | |
| _STL_VERIFY(this->_Has_value, "Cannot access value of empty optional"); | |
| #endif // _CONTAINER_DEBUG_LEVEL > 0 | |
| return _STD move(this->_Value); | |
| } | |
| _NODISCARD constexpr const _Ty&& operator*() const&& { | |
| #if _CONTAINER_DEBUG_LEVEL > 0 | |
| _STL_VERIFY(this->_Has_value, "Cannot access value of empty optional"); | |
| #endif // _CONTAINER_DEBUG_LEVEL > 0 | |
| return _STD move(this->_Value); | |
| } |
These are unconditional.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
LWGLibrary Working Group issueLibrary Working Group issuefixedSomething works now, yay!Something works now, yay!good first issueGood for newcomersGood for newcomers
Type
Projects
Status
Done