mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +00:00
AK: Add constructors to Optional that accept non const qualified inputs
This commit is contained in:
parent
484823e9d5
commit
1da0d402b7
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue