Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
grisumbras opened this issue Oct 9, 2024 · 0 comments
Open

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

grisumbras opened this issue Oct 9, 2024 · 0 comments

Comments

@grisumbras
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant