AK: Add constructors to Optional that accept non const qualified inputs

This commit is contained in:
Itamar 2021-05-08 12:22:57 +03:00 committed by Andreas Kling
parent 484823e9d5
commit 1da0d402b7

View file

@ -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) {