mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +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
Notes:
sideshowbarker
2024-07-19 12:48:58 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/865a1b913cc
1 changed files with 10 additions and 3 deletions
|
@ -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