mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-25 00:11:07 +00:00
base: add == operator to util/attempt.h
This simplifies testing for early return conditions for which the use of lambdas would be quite noisy. genodelabs/genode#4393
This commit is contained in:
parent
024b987e4c
commit
b821776b0d
@ -72,6 +72,12 @@ class Genode::Attempt
|
||||
fail_fn(_error);
|
||||
}
|
||||
|
||||
bool operator == (ERROR const &rhs) const {
|
||||
return failed() && (_error == rhs); }
|
||||
|
||||
bool operator == (RESULT const &rhs) const {
|
||||
return ok() && (_result == rhs); }
|
||||
|
||||
bool ok() const { return _ok; }
|
||||
bool failed() const { return !_ok; }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user