summaryrefslogtreecommitdiff
path: root/AK/Optional.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-24 10:25:43 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-24 10:25:43 +0200
commit1d0b4646180e7a6aa9b2bf6ea45f37d4b156c5d4 (patch)
treea6c990843ea0e304405ae0f8b3bf2116644ae525 /AK/Optional.h
parente2798d6208302a1195cb2888b69034d08dc95d89 (diff)
downloadserenity-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.h4
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 };
};