mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-26 20:38:45 +08:00
Merge branch 'pull-request/#982-Added-return-to-etl-optional-emplace-fixed-typo' into development
This commit is contained in:
commit
3a5b552c82
@ -484,14 +484,16 @@ namespace etl
|
||||
//*************************************************************************
|
||||
template <typename... TArgs>
|
||||
ETL_CONSTEXPR20_STL
|
||||
void emplace(TArgs&& ... args)
|
||||
T& emplace(TArgs&& ... args)
|
||||
{
|
||||
storage.construct(etl::forward<TArgs>(args)...);
|
||||
|
||||
return storage.u.value;
|
||||
}
|
||||
#else
|
||||
//*************************************************************************
|
||||
/// Emplaces a value.
|
||||
/// 1 parameter.
|
||||
/// 0 parameters.
|
||||
//*************************************************************************
|
||||
T& emplace()
|
||||
{
|
||||
@ -1048,14 +1050,16 @@ namespace etl
|
||||
//*************************************************************************
|
||||
template <typename... TArgs>
|
||||
ETL_CONSTEXPR14
|
||||
void emplace(TArgs&& ... args)
|
||||
T& emplace(TArgs&& ... args)
|
||||
{
|
||||
storage.construct(etl::forward<TArgs>(args)...);
|
||||
|
||||
return storage.value;
|
||||
}
|
||||
#else
|
||||
//*************************************************************************
|
||||
/// Emplaces a value.
|
||||
/// 1 parameter.
|
||||
/// 0 parameters.
|
||||
//*************************************************************************
|
||||
T& emplace()
|
||||
{
|
||||
|
||||
@ -157,6 +157,16 @@ namespace
|
||||
CHECK_EQUAL(0, int(result.value()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_emplace_return)
|
||||
{
|
||||
etl::optional<DataM> data;
|
||||
|
||||
DataM* datam = &data.emplace(1U);
|
||||
CHECK_EQUAL(datam, &data.value());
|
||||
CHECK(datam != nullptr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_moveable)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user