From 1da0d402b7f3476b30d7482ba63d8ad5d215dd96 Mon Sep 17 00:00:00 2001 From: Itamar Date: Sat, 8 May 2021 12:22:57 +0300 Subject: [PATCH] AK: Add constructors to Optional that accept non const qualified inputs --- AK/Optional.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/AK/Optional.h b/AK/Optional.h index 2d939ce099..9a1b786da8 100644 --- a/AK/Optional.h +++ b/AK/Optional.h @@ -56,6 +56,21 @@ public: } } + ALWAYS_INLINE Optional(Optional& other) + : m_has_value(other.m_has_value) + { + if (m_has_value) { + new (&m_storage) T(other.value()); + } + } + + template + ALWAYS_INLINE Optional(U& value) + : m_has_value(true) + { + new (&m_storage) T(value); + } + ALWAYS_INLINE Optional& operator=(const Optional& other) { if (this != &other) {