Closed rnburn closed 6 years ago
Thanks!
I guess you know that the error_traits is not part of the current proposal.
The proposal has nothing special for exception_ptr or error_code.
I believe that we can define a non-member non-friend function that could do what we want on top of the proposal.
E.g. we can have value_or_rethrow
that could make use or error_traits
.
In [P0786] I propose a resolve
function that could take a function that rethrows as well.
using namespace value_or_error;
auto v = resolve(e, rethrow);
where retrow would be a polymorphic function that rethrows using the error_traits
.
So value_or_rethrow(e)
coudl be the equivalent to resolve(e, rethrow)
I recognize the syntax of the non-member functions is less friendly for a lot of us, but I believe that we should define the minimal interface in expected
. At the end, expected::value
and expected::value_or
shouldn't be member functions, as we can define them as non-members.
BTW, I'm working with JF Bastien on the wording for the LWG. See https://github.com/jfbastien/papers/blob/master/source/D0323r4.bs
Any contribution is more than welcome.
[d0786r1] https://github.com/viboes/std-make/blob/master/doc/proposal/value_or_error/d0786r1.md
This code should work
But it gives this compilation error:
The believe the specializations for std::exception_ptr should be using std::enable_if instead of regular conditionals.