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.
|
_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:
|
_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.
LWG-2762 asks for
unique_ptrandoptionalindirection operators to benoexceptunique_ptris alreadynoexcept. It is marked as/* strengthened */as thisnoexceptwas 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 viaremove_reference_t<D>::pointer.STL/stl/inc/memory
Line 3210 in dc888f7
So the fix is to change
noexceptto conditional, and remove/* strengthened */comment.optionalmissesnoexcept, it should be added:STL/stl/inc/optional
Lines 345 to 381 in dc888f7
These are unconditional.