mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:07:45 +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
1 changed files with 10 additions and 3 deletions
|
@ -10,15 +10,22 @@ public:
|
||||||
Optional() {}
|
Optional() {}
|
||||||
|
|
||||||
RETURN_TYPESTATE(unknown)
|
RETURN_TYPESTATE(unknown)
|
||||||
Optional(T&& value)
|
Optional(const T& value)
|
||||||
: m_has_value(true)
|
: m_has_value(true)
|
||||||
{
|
{
|
||||||
new (&m_storage) T(move(value));
|
new (&m_storage) T(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
RETURN_TYPESTATE(unknown)
|
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)
|
: m_has_value(true)
|
||||||
{
|
{
|
||||||
new (&m_storage) T(move(value));
|
new (&m_storage) T(move(value));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue