Skip to content

LWG-4015 LWG-3973 broke const overloads of std::optional monadic operations #5871

@StephanTLavavej

Description

@StephanTLavavej

LWG-4015 LWG-3973 broke const overloads of std::optional monadic operations

It looks like this may be unobservable for us right now, especially because in #4158 I noted that the earlier LWG-3973 was "Implemented without comments". However, I do observe variation between our current implementation and LWG-4015's resolution. For example, our converting move constructor says _STD move(*_Right) (i.e. deref optional, then move):

STL/stl/inc/optional

Lines 292 to 296 in ab6dec6

template <class _Ty2, enable_if_t<conjunction_v<_AllowUnwrapping<_Ty2>, is_constructible<_Ty, _Ty2>>, int> = 0>
_CONSTEXPR20 explicit(!is_convertible_v<_Ty2, _Ty>) optional(optional<_Ty2>&& _Right)
noexcept(is_nothrow_constructible_v<_Ty, _Ty2>) /* strengthened */ {
if (_Right) {
this->_Construct(_STD move(*_Right));

But LWG-4015 specifies std::move(rhs).operator*(), i.e. move optional, then deref.

I'll note this issue in #5607 tracking optional<T&>, but I think we can clean up divergence here before implementing that feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LWGLibrary Working Group issue

    Type

    No type

    Projects

    Status

    Available

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions