std-make
std-make copied to clipboard
expected: references
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.
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?