X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fresult.hpp;h=377d5a22539a3491ee4330438bace6476d9567d1;hb=9e29f23cc3afcd33c4735a397ca94b5d7bed3326;hp=fe9956bfd29dd39a84c3f5ea6009501f0f1a9ddf;hpb=54c34361d08386c751897ee215554c9ea1efd108;p=staging%2Fwindowmanager.git diff --git a/src/result.hpp b/src/result.hpp index fe9956b..377d5a2 100644 --- a/src/result.hpp +++ b/src/result.hpp @@ -9,30 +9,34 @@ namespace wm { - using std::experimental::optional; - using std::experimental::nullopt; +using std::experimental::optional; +using std::experimental::nullopt; - // We only ever return a string as an error - so just parametrize - // this over result type T - template - struct result { - char const *e; - optional t; +// We only ever return a string as an error - so just parametrize +// this over result type T +template +struct result { + char const *e; + optional t; - bool is_ok() const { return this->t != nullopt; } - bool is_err() const { return this->e != nullptr; } + bool is_ok() const { return this->t != nullopt; } + bool is_err() const { return this->e != nullptr; } - T unwrap() { return this->t.value(); } + T unwrap() { return this->t.value(); } - char const *unwrap_err() { return this->e; } - }; + char const *unwrap_err() { return this->e; } +}; - template - struct result Err(char const *e) { return result{e, nullopt}; } +template +struct result Err(char const *e) { + return result{e, nullopt}; +} - template - struct result Ok(T t) { return result{nullptr, t}; } +template +struct result Ok(T t) { + return result{nullptr, t}; +} -} // namespace wm +} // namespace wm -#endif //TMCAGLWM_RESULT_HPP +#endif // TMCAGLWM_RESULT_HPP