mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add constructors to Optional that accept non const qualified inputs
This commit is contained in:
parent
484823e9d5
commit
1da0d402b7
Notes:
sideshowbarker
2024-07-18 18:30:39 +09:00
Author: https://github.com/itamar8910 Commit: https://github.com/SerenityOS/serenity/commit/1da0d402b7f Pull-request: https://github.com/SerenityOS/serenity/pull/6944 Reviewed-by: https://github.com/alimpfard
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)
|
||||
{
|
||||
if (this != &other) {
|
||||
|
|
Loading…
Reference in a new issue