diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2018-12-08 10:43:50 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2018-12-08 10:43:50 +0100 |
| commit | 0c1d1a0f24655c22a373c19aac90a6a225a353e6 (patch) | |
| tree | e65fe3c5f8b80bb59910c81c700eb3ed545848bb /src/optional.hpp | |
| parent | f22d1b76c9a957a679b57ddcb67b33cc73a15de1 (diff) | |
| download | wanda-0c1d1a0f24655c22a373c19aac90a6a225a353e6.tar.xz wanda-0c1d1a0f24655c22a373c19aac90a6a225a353e6.zip | |
wanda: reformat source code
Diffstat (limited to 'src/optional.hpp')
| -rw-r--r-- | src/optional.hpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/optional.hpp b/src/optional.hpp index 5e1c630..3c964db 100644 --- a/src/optional.hpp +++ b/src/optional.hpp @@ -11,37 +11,37 @@ namespace wanda::std_ext { - -struct failable -{ + struct failable + { constexpr static auto success() { return failable{false}; } constexpr static auto failure() { return failable{true}; } - template <typename Handler> + template<typename Handler> constexpr auto operator||(Handler handler) const { - if (m_failed) - { - handler(); - } + if (m_failed) + { + handler(); + } } private: - constexpr explicit failable(bool failed) : m_failed{failed} {}; + constexpr explicit failable(bool failed) + : m_failed{failed} {}; bool const m_failed; -}; + }; -template <typename ObjectType, typename HandlerType> -auto with(std::optional<ObjectType> &&object, HandlerType handler) -{ + template<typename ObjectType, typename HandlerType> + auto with(std::optional<ObjectType> && object, HandlerType handler) + { if (object) { - handler(object.value()); - return failable::success(); + handler(object.value()); + return failable::success(); } return failable::failure(); -} + } -} // namespace wanda::std_ext +} // namespace wanda::std_ext #endif
\ No newline at end of file |
