mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-23 11:04:40 +00:00
AK: Add Optional<T>(const U&)
This replaces Optional<T>(U&&) which clang-tidy complained may hide the regular copy and move constructors. That's a good point, clang-tidy, and I appreciate you pointing that out!
This commit is contained in:
parent
533b5c0adc
commit
865a1b913c
|
@ -10,15 +10,22 @@ public:
|
|||
Optional() {}
|
||||
|
||||
RETURN_TYPESTATE(unknown)
|
||||
Optional(T&& value)
|
||||
Optional(const T& value)
|
||||
: m_has_value(true)
|
||||
{
|
||||
new (&m_storage) T(move(value));
|
||||
new (&m_storage) T(value);
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
RETURN_TYPESTATE(unknown)
|
||||
Optional(U&& value)
|
||||
Optional(const U& value)
|
||||
: m_has_value(true)
|
||||
{
|
||||
new (&m_storage) T(value);
|
||||
}
|
||||
|
||||
RETURN_TYPESTATE(unknown)
|
||||
Optional(T&& value)
|
||||
: m_has_value(true)
|
||||
{
|
||||
new (&m_storage) T(move(value));
|
||||
|
|
Loading…
Reference in a new issue