-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
It has been argued that the error should be always available and that often there is a success value associated to the error.
expected <E,T> would be seen more like something struct { E; optional<T> }.
The following code was show as use case
auto e = function();
switch (e.status()) {
success: ....; break;
too_green: ....; break;
too_pink: ....; break;
}This could be done with the current interface as follows
auto e = function();
switch (error_or(e, success)) {
success: ....; break;
too_green: ....; break;
too_pink: ....; break;
}where
template <class E, class T>
E error_or(expected<E,T> const&, E err) {
if(e) return err;
else return error();
}Do we need to add such a error_or function? as member?
Reactions are currently unavailable