mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
parent
3623ba5b38
commit
82c2f8a26d
@ -764,12 +764,6 @@ namespace etl
|
||||
template <typename ... Args>
|
||||
ETL_CONSTEXPR14 void emplace(Args && ... args)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
// Destroy the old one.
|
||||
storage.template get_reference<T>().~T();
|
||||
}
|
||||
|
||||
storage = T(ETL_OR_STD::forward<Args>(args)...);
|
||||
valid = true;
|
||||
}
|
||||
|
||||
@ -484,5 +484,15 @@ namespace
|
||||
|
||||
CHECK_EQUAL(false, result.has_value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_optional_emplace_bug_636)
|
||||
{
|
||||
etl::optional<std::uint8_t> result = 1;
|
||||
result.emplace(2);
|
||||
|
||||
CHECK_TRUE(result.has_value());
|
||||
CHECK_EQUAL(2, result.value());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user