diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-24 10:25:43 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-24 10:25:43 +0200 |
commit | 1d0b4646180e7a6aa9b2bf6ea45f37d4b156c5d4 (patch) | |
tree | a6c990843ea0e304405ae0f8b3bf2116644ae525 /AK/Optional.h | |
parent | e2798d6208302a1195cb2888b69034d08dc95d89 (diff) | |
download | serenity-1d0b4646180e7a6aa9b2bf6ea45f37d4b156c5d4.zip |
AK: Make HashMap::get(Key) return an Optional<Value>.
This allows HashMap::get() to be used for value types that cannot be default
constructed (e.g NonnullOwnPtr.)
Diffstat (limited to 'AK/Optional.h')
-rw-r--r-- | AK/Optional.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/AK/Optional.h b/AK/Optional.h index 9dbef306fb..9af81ac13e 100644 --- a/AK/Optional.h +++ b/AK/Optional.h @@ -103,7 +103,9 @@ public: return fallback; } + operator bool() const { return has_value(); } + private: - char m_storage[sizeof(T)] __attribute__((aligned(sizeof(T)))); + char m_storage[sizeof(T)]; bool m_has_value { false }; }; |