diff options
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Optional.h | 15 |
1 files changed, 15 insertions, 0 deletions
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<typename U> + ALWAYS_INLINE Optional(U& value) + : m_has_value(true) + { + new (&m_storage) T(value); + } + ALWAYS_INLINE Optional& operator=(const Optional& other) { if (this != &other) { |