summaryrefslogtreecommitdiff
path: root/AK/Optional.h
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-12-30 21:16:37 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-31 00:51:12 +0100
commita7c014125fcf82be8c3cb39398e439babe21c99f (patch)
treec7154f88095cfc827b80a4d7269020cdd20a186d /AK/Optional.h
parentc770b0bbeca06150d74f888f01649b2e37058448 (diff)
downloadserenity-a7c014125fcf82be8c3cb39398e439babe21c99f.zip
AK: Add operator* and operator-> overloads in Optional.
Diffstat (limited to 'AK/Optional.h')
-rw-r--r--AK/Optional.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/AK/Optional.h b/AK/Optional.h
index 092cdc6e9f..f2fd929fb3 100644
--- a/AK/Optional.h
+++ b/AK/Optional.h
@@ -155,6 +155,12 @@ public:
return fallback;
}
+ const T& operator*() const { return value(); }
+ T& operator*() { return value(); }
+
+ const T* operator->() const { return &value(); }
+ T* operator->() { return &value(); }
+
private:
// Call when we don't want to alter the consume state
ALWAYS_INLINE const T& value_without_consume_state() const