Skip to content

Request for additional overload of operator|(result<T&>, U) #128

Open
@grisumbras

Description

@grisumbras

Consider this: https://godbolt.org/z/qK4GTrdYM

The decay function is only needed there, because try_at returns result<value const&>, and the righthand operand of operator| is not convertible to value const&.

Given that operator| is used for providing a default, and the default usually doesn't exist before it is required, most of the time you don't want to return a result<T&>, even if the source is a result<T&>.

I can suggest adding result<T> operator|(result<T&>, U) overload that matches if U is convertible to std::decay_t<T&>. Same for function overloads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions