
23 Jan
2018
23 Jan
'18
6:30 a.m.
On 23/01/2018 12:50, Peter Dimov wrote:
Andrzej Krzemienski wrote:
This could be handled by providing a dedicated heterogeneous comparison between `result
` and `EC`. I prefer `if( !r && r.error() == condition )`. Similarly, `r? *r: x` instead of `r.value_or(x)`.
This is actually a good example of why operator bool might be a bad idea. It's not too controversial for result<>, but in outcome<> "!r" will be true if there isn't a value, but "r.error()" might throw or UB in that case if it has an exception without an error code. So the long-form of that test would be: if ( r.has_error() && r.error() == condition )