diff options
author | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-07-28 15:05:53 +0200 |
---|---|---|
committer | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-08-08 17:24:00 +0200 |
commit | bd3363946030c35ed5b795d5b30d5d2a34aaad84 (patch) | |
tree | 7ab2dc9099ed819acd1a9f8ed4d44ebd675deb1a /src | |
parent | 626b0fc7a92da537f4914afcd3ff390f855785c4 (diff) |
result: return nullopt if error is actuall nullptr
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/result.hpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/result.hpp b/src/result.hpp index b740a0c..5701f24 100644 --- a/src/result.hpp +++ b/src/result.hpp @@ -30,14 +30,14 @@ struct result { return this->t.value(); } - operator T() { - return this->unwrap(); - } + operator T() { return this->unwrap(); } char const *unwrap_err() { return this->e; } - optional<T> ok() const { return this->t; } - optional<char const *> err() const { return optional<char const *>(this->e); } + optional<T> const &ok() const { return this->t; } + optional<char const *> err() const { + return this->e ? optional<char const *>(this->e) : nullopt; + } result<T> map_err(std::function<char const *(char const *)> f); }; |