mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:07:45 +00:00
AK: Add constructors to Optional that accept non const qualified inputs
This commit is contained in:
parent
484823e9d5
commit
1da0d402b7
1 changed files with 15 additions and 0 deletions
|
@ -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)
|
ALWAYS_INLINE Optional& operator=(const Optional& other)
|
||||||
{
|
{
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue