summaryrefslogtreecommitdiffstats
path: root/src/result.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/result.hpp')
-rw-r--r--src/result.hpp42
1 files changed, 23 insertions, 19 deletions
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<typename T>
- struct result {
- char const *e;
- optional<T> t;
+// We only ever return a string as an error - so just parametrize
+// this over result type T
+template <typename T>
+struct result {
+ char const *e;
+ optional<T> 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<typename T>
- struct result<T> Err(char const *e) { return result<T>{e, nullopt}; }
+template <typename T>
+struct result<T> Err(char const *e) {
+ return result<T>{e, nullopt};
+}
- template<typename T>
- struct result<T> Ok(T t) { return result<T>{nullptr, t}; }
+template <typename T>
+struct result<T> Ok(T t) {
+ return result<T>{nullptr, t};
+}
-} // namespace wm
+} // namespace wm
-#endif //TMCAGLWM_RESULT_HPP
+#endif // TMCAGLWM_RESULT_HPP