diff options
author | Robin Burchell <robin+git@viroteck.net> | 2019-05-28 11:53:16 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-28 17:31:20 +0200 |
commit | 0dc9af5f7e26b0dfa42cb75c900b9ef7a2192425 (patch) | |
tree | 93dbbbeb714f258bd7fb044633eb83bdcd908286 /Kernel/KResult.h | |
parent | c11351ac507f863699d78aec46a77bd4d59e743c (diff) | |
download | serenity-0dc9af5f7e26b0dfa42cb75c900b9ef7a2192425.zip |
Add clang-format file
Also run it across the whole tree to get everything using the One True Style.
We don't yet run this in an automated fashion as it's a little slow, but
there is a snippet to do so in makeall.sh.
Diffstat (limited to 'Kernel/KResult.h')
-rw-r--r-- | Kernel/KResult.h | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/Kernel/KResult.h b/Kernel/KResult.h index 1cc740bc74..291e9ea2ea 100644 --- a/Kernel/KResult.h +++ b/Kernel/KResult.h @@ -3,20 +3,31 @@ #include <AK/Assertions.h> #include <LibC/errno_numbers.h> -enum KSuccessTag { KSuccess }; +enum KSuccessTag +{ + KSuccess +}; class KResult { public: - explicit KResult(int negative_e) : m_error(negative_e) { ASSERT(negative_e <= 0); } - KResult(KSuccessTag) : m_error(0) { } + explicit KResult(int negative_e) + : m_error(negative_e) + { + ASSERT(negative_e <= 0); + } + KResult(KSuccessTag) + : m_error(0) + { + } operator int() const { return m_error; } bool is_success() const { return m_error == ESUCCESS; } bool is_error() const { return !is_success(); } private: - template<typename T> friend class KResultOr; - KResult() { } + template<typename T> + friend class KResultOr; + KResult() {} int m_error { 0 }; }; @@ -27,7 +38,8 @@ public: KResultOr(KResult error) : m_error(error) , m_is_error(true) - { } + { + } KResultOr(T&& value) { @@ -54,9 +66,21 @@ public: } bool is_error() const { return m_is_error; } - KResult error() const { ASSERT(m_is_error); return m_error; } - T& value() { ASSERT(!m_is_error); return *reinterpret_cast<T*>(&m_storage); } - const T& value() const { ASSERT(!m_is_error); return *reinterpret_cast<T*>(&m_storage); } + KResult error() const + { + ASSERT(m_is_error); + return m_error; + } + T& value() + { + ASSERT(!m_is_error); + return *reinterpret_cast<T*>(&m_storage); + } + const T& value() const + { + ASSERT(!m_is_error); + return *reinterpret_cast<T*>(&m_storage); + } T release_value() { @@ -71,4 +95,3 @@ private: KResult m_error; bool m_is_error { false }; }; - |