emplace member functions return reference to emplaced value (#659)

This commit is contained in:
Alex Hirsch 2023-01-07 13:18:55 +01:00 committed by GitHub
parent f0f23ebc11
commit a507f8f2a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 149 additions and 40 deletions

View File

@ -1742,7 +1742,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
template <typename ... Args>
void emplace_back(Args && ... args)
reference emplace_back(Args && ... args)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
@ -1752,6 +1752,7 @@ namespace etl
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
return back();
}
#else
@ -1761,7 +1762,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
template <typename T1>
void emplace_back(const T1& value1)
reference emplace_back(const T1& value1)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
@ -1771,6 +1772,7 @@ namespace etl
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
return back();
}
//*************************************************************************
@ -1778,7 +1780,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
template <typename T1, typename T2>
void emplace_back(const T1& value1, const T2& value2)
reference emplace_back(const T1& value1, const T2& value2)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
@ -1788,6 +1790,7 @@ namespace etl
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
return back();
}
//*************************************************************************
@ -1795,7 +1798,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
template <typename T1, typename T2, typename T3>
void emplace_back(const T1& value1, const T2& value2, const T3& value3)
reference emplace_back(const T1& value1, const T2& value2, const T3& value3)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
@ -1805,6 +1808,7 @@ namespace etl
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
return back();
}
//*************************************************************************
@ -1812,7 +1816,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
template <typename T1, typename T2, typename T3, typename T4>
void emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
reference emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
@ -1822,6 +1826,7 @@ namespace etl
++_end;
++current_size;
ETL_INCREMENT_DEBUG_COUNT
return back();
}
#endif
@ -1870,7 +1875,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
template <typename ... Args>
void emplace_front(Args && ... args)
reference emplace_front(Args && ... args)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
@ -1880,6 +1885,7 @@ namespace etl
::new (&(*_begin)) T(etl::forward<Args>(args)...);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
return front();
}
#else
@ -1889,7 +1895,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
template <typename T1>
void emplace_front(const T1& value1)
reference emplace_front(const T1& value1)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
@ -1899,6 +1905,7 @@ namespace etl
::new (&(*_begin)) T(value1);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
return front();
}
//*************************************************************************
@ -1906,7 +1913,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
template <typename T1, typename T2>
void emplace_front(const T1& value1, const T2& value2)
reference emplace_front(const T1& value1, const T2& value2)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
@ -1916,6 +1923,7 @@ namespace etl
::new (&(*_begin)) T(value1, value2);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
return front();
}
//*************************************************************************
@ -1923,7 +1931,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
template <typename T1, typename T2, typename T3>
void emplace_front(const T1& value1, const T2& value2, const T3& value3)
reference emplace_front(const T1& value1, const T2& value2, const T3& value3)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
@ -1933,6 +1941,7 @@ namespace etl
::new (&(*_begin)) T(value1, value2, value3);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
return front();
}
//*************************************************************************
@ -1940,7 +1949,7 @@ namespace etl
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
//*************************************************************************
template <typename T1, typename T2, typename T3, typename T4>
void emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
reference emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
@ -1950,6 +1959,7 @@ namespace etl
::new (&(*_begin)) T(value1, value2, value3, value4);
++current_size;
ETL_INCREMENT_DEBUG_COUNT
return front();
}
#endif

View File

@ -722,7 +722,7 @@ namespace etl
/// Emplaces a value to the front of the list..
//*************************************************************************
template <typename ... Args>
void emplace_front(Args && ... args)
reference emplace_front(Args && ... args)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
@ -731,13 +731,14 @@ namespace etl
::new (&(p_data_node->value)) T(etl::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT
insert_node_after(start_node, *p_data_node);
return front();
}
#else
//*************************************************************************
/// Emplaces a value to the front of the list..
//*************************************************************************
template <typename T1>
void emplace_front(const T1& value1)
reference emplace_front(const T1& value1)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
@ -746,13 +747,14 @@ namespace etl
::new (&(p_data_node->value)) T(value1);
ETL_INCREMENT_DEBUG_COUNT
insert_node_after(start_node, *p_data_node);
return front();
}
//*************************************************************************
/// Emplaces a value to the front of the list..
//*************************************************************************
template <typename T1, typename T2>
void emplace_front(const T1& value1, const T2& value2)
reference emplace_front(const T1& value1, const T2& value2)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
@ -761,13 +763,14 @@ namespace etl
::new (&(p_data_node->value)) T(value1, value2);
ETL_INCREMENT_DEBUG_COUNT
insert_node_after(start_node, *p_data_node);
return front();
}
//*************************************************************************
/// Emplaces a value to the front of the list..
//*************************************************************************
template <typename T1, typename T2, typename T3>
void emplace_front(const T1& value1, const T2& value2, const T3& value3)
reference emplace_front(const T1& value1, const T2& value2, const T3& value3)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
@ -776,13 +779,14 @@ namespace etl
::new (&(p_data_node->value)) T(value1, value2, value3);
ETL_INCREMENT_DEBUG_COUNT
insert_node_after(start_node, *p_data_node);
return front();
}
//*************************************************************************
/// Emplaces a value to the front of the list..
//*************************************************************************
template <typename T1, typename T2, typename T3, typename T4>
void emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
reference emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
@ -791,6 +795,7 @@ namespace etl
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
ETL_INCREMENT_DEBUG_COUNT
insert_node_after(start_node, *p_data_node);
return front();
}
#endif // ETL_USING_CPP11 && ETL_NOT_USING_STLPORT

View File

@ -782,10 +782,11 @@ namespace etl
///\param value The value to add.
//*********************************************************************
template <typename ... Args>
void emplace_back(Args && ... args)
reference emplace_back(Args && ... args)
{
T* p = storage.create<T>(etl::forward<Args>(args)...);
lookup.push_back(p);
return back();
}
#else
//*********************************************************************
@ -794,10 +795,11 @@ namespace etl
///\param value The value to add.
//*********************************************************************
template <typename T1>
void emplace_back(const T1& value1)
reference emplace_back(const T1& value1)
{
T* p = storage.create<T>(T(value1));
lookup.push_back(p);
return back();
}
//*********************************************************************
@ -806,10 +808,11 @@ namespace etl
///\param value The value to add.
//*********************************************************************
template <typename T1, typename T2>
void emplace_back(const T1& value1, const T2& value2)
reference emplace_back(const T1& value1, const T2& value2)
{
T* p = storage.create<T>(T(value1, value2));
lookup.push_back(p);
return back();
}
//*********************************************************************
@ -818,10 +821,11 @@ namespace etl
///\param value The value to add.
//*********************************************************************
template <typename T1, typename T2, typename T3>
void emplace_back(const T1& value1, const T2& value2, const T3& value3)
reference emplace_back(const T1& value1, const T2& value2, const T3& value3)
{
T* p = storage.create<T>(T(value1, value2, value3));
lookup.push_back(p);
return back();
}
//*********************************************************************
@ -830,10 +834,11 @@ namespace etl
///\param value The value to add.
//*********************************************************************
template <typename T1, typename T2, typename T3, typename T4>
void emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
reference emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{
T* p = storage.create<T>(T(value1, value2, value3, value4));
lookup.push_back(p);
return back();
}
#endif

View File

@ -862,7 +862,7 @@ namespace etl
/// Emplaces a value to the front of the list.
//*************************************************************************
template <typename ... Args>
void emplace_front(Args && ... args)
reference emplace_front(Args && ... args)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
@ -873,13 +873,14 @@ namespace etl
::new (&(p_data_node->value)) T(etl::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT
insert_node(get_head(), *p_data_node);
return front();
}
#else
//*************************************************************************
/// Emplaces a value to the front of the list.
//*************************************************************************
template <typename T1>
void emplace_front(const T1& value1)
reference emplace_front(const T1& value1)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
@ -890,13 +891,14 @@ namespace etl
::new (&(p_data_node->value)) T(value1);
ETL_INCREMENT_DEBUG_COUNT
insert_node(get_head(), *p_data_node);
return front();
}
//*************************************************************************
/// Emplaces a value to the front of the list.
//*************************************************************************
template <typename T1, typename T2>
void emplace_front(const T1& value1, const T2& value2)
reference emplace_front(const T1& value1, const T2& value2)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
@ -907,13 +909,14 @@ namespace etl
::new (&(p_data_node->value)) T(value1, value2);
ETL_INCREMENT_DEBUG_COUNT
insert_node(get_head(), *p_data_node);
return front();
}
//*************************************************************************
/// Emplaces a value to the front of the list.
//*************************************************************************
template <typename T1, typename T2, typename T3>
void emplace_front(const T1& value1, const T2& value2, const T3& value3)
reference emplace_front(const T1& value1, const T2& value2, const T3& value3)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
@ -924,13 +927,14 @@ namespace etl
::new (&(p_data_node->value)) T(value1, value2, value3);
ETL_INCREMENT_DEBUG_COUNT
insert_node(get_head(), *p_data_node);
return front();
}
//*************************************************************************
/// Emplaces a value to the front of the list.
//*************************************************************************
template <typename T1, typename T2, typename T3, typename T4>
void emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
reference emplace_front(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
@ -941,6 +945,7 @@ namespace etl
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
ETL_INCREMENT_DEBUG_COUNT
insert_node(get_head(), *p_data_node);
return front();
}
#endif
@ -985,7 +990,7 @@ namespace etl
//*************************************************************************
#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
template <typename ... Args>
void emplace_back(Args && ... args)
reference emplace_back(Args && ... args)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
@ -996,10 +1001,11 @@ namespace etl
::new (&(p_data_node->value)) T(etl::forward<Args>(args)...);
ETL_INCREMENT_DEBUG_COUNT
insert_node(terminal_node, *p_data_node);
return back();
}
#else
template <typename T1>
void emplace_back(const T1& value1)
reference emplace_back(const T1& value1)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
@ -1010,10 +1016,11 @@ namespace etl
::new (&(p_data_node->value)) T(value1);
ETL_INCREMENT_DEBUG_COUNT
insert_node(terminal_node, *p_data_node);
return back();
}
template <typename T1, typename T2>
void emplace_back(const T1& value1, const T2& value2)
reference emplace_back(const T1& value1, const T2& value2)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
@ -1024,10 +1031,11 @@ namespace etl
::new (&(p_data_node->value)) T(value1, value2);
ETL_INCREMENT_DEBUG_COUNT
insert_node(terminal_node, *p_data_node);
return back();
}
template <typename T1, typename T2, typename T3>
void emplace_back(const T1& value1, const T2& value2, const T3& value3)
reference emplace_back(const T1& value1, const T2& value2, const T3& value3)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
@ -1038,10 +1046,11 @@ namespace etl
::new (&(p_data_node->value)) T(value1, value2, value3);
ETL_INCREMENT_DEBUG_COUNT
insert_node(terminal_node, *p_data_node);
return back();
}
template <typename T1, typename T2, typename T3, typename T4>
void emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
reference emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(!full(), ETL_ERROR(list_full));
@ -1052,6 +1061,7 @@ namespace etl
::new (&(p_data_node->value)) T(value1, value2, value3, value4);
ETL_INCREMENT_DEBUG_COUNT
insert_node(terminal_node, *p_data_node);
return back();
}
#endif

View File

@ -427,7 +427,7 @@ namespace etl
///\param args The arguments to construct with.
//*************************************************************************
template <typename ... Args>
void emplace(Args && ... args)
T& emplace(Args && ... args)
{
if (valid)
{
@ -437,6 +437,7 @@ namespace etl
::new (storage.template get_address<T>()) T(ETL_OR_STD::forward<Args>(args)...);
valid = true;
return storage;
}
#else
//*************************************************************************
@ -444,7 +445,7 @@ namespace etl
/// 1 parameter.
//*************************************************************************
template <typename T1>
void emplace(const T1& value1)
T& emplace(const T1& value1)
{
if (valid)
{
@ -454,6 +455,7 @@ namespace etl
::new (storage.template get_address<T>()) T(value1);
valid = true;
return storage;
}
//*************************************************************************
@ -461,7 +463,7 @@ namespace etl
/// 2 parameters.
//*************************************************************************
template <typename T1, typename T2>
void emplace(const T1& value1, const T2& value2)
T& emplace(const T1& value1, const T2& value2)
{
if (valid)
{
@ -471,6 +473,7 @@ namespace etl
::new (storage.template get_address<T>()) T(value1, value2);
valid = true;
return storage;
}
//*************************************************************************
@ -478,7 +481,7 @@ namespace etl
/// 3 parameters.
//*************************************************************************
template <typename T1, typename T2, typename T3>
void emplace(const T1& value1, const T2& value2, const T3& value3)
T& emplace(const T1& value1, const T2& value2, const T3& value3)
{
if (valid)
{
@ -488,6 +491,7 @@ namespace etl
::new (storage.template get_address<T>()) T(value1, value2, value3);
valid = true;
return storage;
}
//*************************************************************************
@ -495,7 +499,7 @@ namespace etl
/// 4 parameters.
//*************************************************************************
template <typename T1, typename T2, typename T3, typename T4>
void emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
T& emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{
if (valid)
{
@ -505,6 +509,7 @@ namespace etl
::new (storage.template get_address<T>()) T(value1, value2, value3, value4);
valid = true;
return storage;
}
#endif

View File

@ -459,7 +459,7 @@ namespace etl
///\param value The value to add.
//*********************************************************************
template <typename ... Args>
void emplace_back(Args && ... args)
reference emplace_back(Args && ... args)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
@ -467,6 +467,7 @@ namespace etl
::new (p_end) T(etl::forward<Args>(args)...);
++p_end;
ETL_INCREMENT_DEBUG_COUNT
return back();
}
#else
//*********************************************************************
@ -475,7 +476,7 @@ namespace etl
///\param value The value to add.
//*********************************************************************
template <typename T1>
void emplace_back(const T1& value1)
reference emplace_back(const T1& value1)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
@ -483,6 +484,7 @@ namespace etl
::new (p_end) T(value1);
++p_end;
ETL_INCREMENT_DEBUG_COUNT
return back();
}
//*********************************************************************
@ -491,7 +493,7 @@ namespace etl
///\param value The value to add.
//*********************************************************************
template <typename T1, typename T2>
void emplace_back(const T1& value1, const T2& value2)
reference emplace_back(const T1& value1, const T2& value2)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
@ -499,6 +501,7 @@ namespace etl
::new (p_end) T(value1, value2);
++p_end;
ETL_INCREMENT_DEBUG_COUNT
return back();
}
//*********************************************************************
@ -507,7 +510,7 @@ namespace etl
///\param value The value to add.
//*********************************************************************
template <typename T1, typename T2, typename T3>
void emplace_back(const T1& value1, const T2& value2, const T3& value3)
reference emplace_back(const T1& value1, const T2& value2, const T3& value3)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
@ -515,6 +518,7 @@ namespace etl
::new (p_end) T(value1, value2, value3);
++p_end;
ETL_INCREMENT_DEBUG_COUNT
return back();
}
//*********************************************************************
@ -523,7 +527,7 @@ namespace etl
///\param value The value to add.
//*********************************************************************
template <typename T1, typename T2, typename T3, typename T4>
void emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
reference emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
{
#if defined(ETL_CHECK_PUSH_POP)
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
@ -531,6 +535,7 @@ namespace etl
::new (p_end) T(value1, value2, value3, value4);
++p_end;
ETL_INCREMENT_DEBUG_COUNT
return back();
}
#endif

View File

@ -1490,6 +1490,15 @@ namespace
CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin()));
}
//*************************************************************************
TEST(test_emplace_back_return)
{
DataNDC data;
auto& back = data.emplace_back("42");
CHECK_EQUAL(back, data.back());
}
//*************************************************************************
TEST(test_push_back_excess)
{
@ -1602,6 +1611,15 @@ namespace
CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin()));
}
//*************************************************************************
TEST(test_emplace_front_return)
{
DataNDC data;
auto& front = data.emplace_front("42");
CHECK_EQUAL(front, data.front());
}
//*************************************************************************
TEST(test_push_front_excess)
{

View File

@ -694,6 +694,15 @@ namespace
CHECK(are_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_emplace_front_return)
{
DataNDC data;
auto& front = data.emplace_front("42");
CHECK_EQUAL(front, data.front());
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_emplace_after)
{

View File

@ -715,6 +715,16 @@ namespace
CHECK(is_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_emplace_back_return)
{
DataNDC data;
std::string value("A");
auto& back = data.emplace_back(value);
CHECK_EQUAL(back, data.back());
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_push_back_unique_ptr)
{

View File

@ -731,6 +731,15 @@ namespace
CHECK(are_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_emplace_front_return)
{
DataNDC data;
auto& front = data.emplace_front("42");
CHECK_EQUAL(front, data.front());
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_push_front_excess)
{
@ -887,6 +896,15 @@ namespace
CHECK(are_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_emplace_back_return)
{
DataNDC data;
auto& back = data.emplace_back("42");
CHECK_EQUAL(back, data.back());
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_push_back_excess)
{

View File

@ -127,6 +127,13 @@ namespace
CHECK_EQUAL(1, DataM::get_instance_count());
}
//*************************************************************************
TEST(test_emplace_return)
{
etl::optional<DataM> data;
CHECK_EQUAL(42U, data.emplace(42U).value);
}
//*************************************************************************
TEST(test_moveable)
{

View File

@ -659,6 +659,13 @@ namespace
CHECK(is_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_emplace_back_return)
{
Data data;
CHECK_EQUAL(42, data.emplace_back(42));
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_push_back_literal)
{