From: Marcus Fritzsch Date: Fri, 28 Jul 2017 13:05:53 +0000 (+0200) Subject: result: return nullopt if error is actuall nullptr X-Git-Tag: 4.99.1~213 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=bd3363946030c35ed5b795d5b30d5d2a34aaad84;p=staging%2Fwindowmanager.git result: return nullopt if error is actuall nullptr Signed-off-by: Marcus Fritzsch --- 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 ok() const { return this->t; } - optional err() const { return optional(this->e); } + optional const &ok() const { return this->t; } + optional err() const { + return this->e ? optional(this->e) : nullopt; + } result map_err(std::function f); };