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

expected: references #31

Open
timrae opened this issue Oct 18, 2017 · 1 comment
Open

expected: references #31

timrae opened this issue Oct 18, 2017 · 1 comment

Comments

@timrae
Copy link

timrae commented Oct 18, 2017

Hi, I really appreciate all your work on this proposal, I really think it would be great if std::expected made it into the standard.

I have one "feature request": In the current proposal you say:

This proposal doesn't include expected references as optional [C++17] doesn't include references either. We need a future proposal.

I don't think this is a meaningful comparison. optional<T&> adds no extra functionality compared to T*, so I assume the committee probably thought it was a waste of time. On the other hand, expected<T&, Error> clearly adds additional functionality compared to T*.

In my company we have tried to take an approach similar to std::expected, packaging an optional together with an error, but it didn't get received well because of the lack of references. Nobody wants to use std::expected<std::reference_wrapper<T>, Error> as the return type to a function in an API.

@viboes
Copy link
Owner

viboes commented Oct 18, 2017

Thanks for your support.

I believe we need a separate proposal with a good motivation and an implementation.
This is not in my priority list at this moment.

I would appreciate if someone else did it.
There are some things I believe the paper should explain. Why we don't have vector<T&>?
How often do we need it an in which cases?

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

No branches or pull requests

2 participants