Open pdimov opened 1 year ago
More like r | x
-> r? *r: x
, and similarly r | f
-> r? *r: f()
.
r &= f;
-> if( r ) r = f(*r);
r |= x;
-> if( !r ) r = x;
r |= f;
-> if( !r ) r = f();
Implemented on develop (without |=
which is deemed unnecessary.)
In the future, maybe consider error-transforming variants of |
, as in
r | f
-> r? *r: f( r.error() )
r |= x
should probably be provided for consistency, always with the effective semantics of r = r | x
.
It only makes sense for r |= f;
where f
returns result
, but it's probably less surprising to just support all the cases.
r |= x
implemented on develop.
r & f
->r? f(*r): r.error()
r | x
->r? r: x
r | f
->r? r: f()
https://godbolt.org/z/YWKKbq859