mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
parent
3cb35ffd7c
commit
8e9eaf4f7c
@ -921,6 +921,67 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is full.
|
||||
///\param insert_position>The insert position.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
iterator emplace(const_iterator insert_position, Args && ... args)
|
||||
{
|
||||
iterator position(insert_position.index, *this, p_buffer);
|
||||
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
|
||||
void* p;
|
||||
|
||||
if (insert_position == begin())
|
||||
{
|
||||
--_begin;
|
||||
p = etl::addressof(*_begin);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _begin;
|
||||
}
|
||||
else if (insert_position == end())
|
||||
{
|
||||
p = etl::addressof(*_end);
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _end - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Are we closer to the front?
|
||||
if (std::distance(_begin, position) < std::distance(position, _end - 1))
|
||||
{
|
||||
// Construct the _begin.
|
||||
create_element_front(*_begin);
|
||||
|
||||
// Move the values.
|
||||
std::copy(_begin + 1, position, _begin);
|
||||
|
||||
// Write the new value.
|
||||
--position;
|
||||
(*position).~T();
|
||||
p = etl::addressof(*position);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Construct the _end.
|
||||
create_element_back(*(_end - 1));
|
||||
|
||||
// Move the values.
|
||||
std::copy_backward(position, _end - 2, _end - 1);
|
||||
|
||||
// Write the new value.
|
||||
(*position).~T();
|
||||
p = etl::addressof(*position);
|
||||
}
|
||||
}
|
||||
|
||||
::new (p) T(std::forward<Args>(args)...);
|
||||
|
||||
return position;
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
iterator emplace(const_iterator insert_position, const T1& value1)
|
||||
{
|
||||
@ -981,11 +1042,6 @@ namespace etl
|
||||
return position;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces data into the deque.
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is full.
|
||||
///\param insert_position>The insert position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
iterator emplace(const_iterator insert_position, const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -1046,11 +1102,6 @@ namespace etl
|
||||
return position;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces data into the deque.
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is full.
|
||||
///\param insert_position>The insert position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
iterator emplace(const_iterator insert_position, const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -1111,11 +1162,6 @@ namespace etl
|
||||
return position;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces data into the deque.
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is full.
|
||||
///\param insert_position>The insert position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
iterator emplace(const_iterator insert_position, const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -1175,6 +1221,7 @@ namespace etl
|
||||
|
||||
return position;
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Inserts 'n' copies of a value into the deque.
|
||||
@ -1512,6 +1559,20 @@ namespace etl
|
||||
/// Emplaces an item to the back of the deque.
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
void emplace_back(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
#endif
|
||||
|
||||
::new (&(*_end)) T(std::forward<Args>(args)...);
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
void emplace_back(const T1& value1)
|
||||
{
|
||||
@ -1525,10 +1586,6 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces an item to the back of the deque.
|
||||
/// 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)
|
||||
{
|
||||
@ -1542,10 +1599,6 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces an item to the back of the deque.
|
||||
/// 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)
|
||||
{
|
||||
@ -1559,10 +1612,6 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces an item to the back of the deque.
|
||||
/// 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)
|
||||
{
|
||||
@ -1575,6 +1624,7 @@ namespace etl
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Removes the oldest item from the deque.
|
||||
@ -1604,6 +1654,20 @@ namespace etl
|
||||
/// Emplaces an item to the front of the deque.
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
void emplace_front(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(deque_full));
|
||||
#endif
|
||||
|
||||
--_begin;
|
||||
::new (&(*_begin)) T(std::forward<Args>(args)...);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
void emplace_front(const T1& value1)
|
||||
{
|
||||
@ -1617,10 +1681,6 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces an item to the front of the deque.
|
||||
/// 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)
|
||||
{
|
||||
@ -1634,10 +1694,6 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces an item to the front of the deque.
|
||||
/// 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)
|
||||
{
|
||||
@ -1651,10 +1707,6 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces an item to the front of the deque.
|
||||
/// 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)
|
||||
{
|
||||
@ -1667,6 +1719,7 @@ namespace etl
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Removes the oldest item from the deque.
|
||||
|
||||
@ -384,6 +384,36 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, Args && ... args)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_map_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
|
||||
::new ((void*)etl::addressof(pvalue->second)) mapped_type(std::forward<Args>(args)...);
|
||||
|
||||
iterator i_element = lower_bound(key);
|
||||
|
||||
std::pair<iterator, bool> result(i_element, false);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (i_element->first != key)))
|
||||
{
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
pvalue->~value_type();
|
||||
storage.release(pvalue);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1)
|
||||
{
|
||||
@ -413,9 +443,6 @@ namespace etl
|
||||
return result;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -445,9 +472,6 @@ namespace etl
|
||||
return result;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -477,9 +501,6 @@ namespace etl
|
||||
return result;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -508,6 +529,7 @@ namespace etl
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases an element.
|
||||
|
||||
@ -323,6 +323,22 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, Args && ... args)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new ((void*)etl::addressof(pvalue->first)) key_type(key);
|
||||
::new ((void*)etl::addressof(pvalue->second)) mapped_type(std::forward<Args>(args)...);
|
||||
iterator i_element = lower_bound(key);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1)
|
||||
{
|
||||
@ -338,9 +354,6 @@ namespace etl
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -356,9 +369,6 @@ namespace etl
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -374,9 +384,6 @@ namespace etl
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -391,6 +398,7 @@ namespace etl
|
||||
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases an element.
|
||||
|
||||
@ -281,6 +281,22 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
std::pair<iterator, bool> emplace(Args && ... args)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(std::forward<Args>(args)...);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
std::pair<iterator, bool> emplace(const T1& value1)
|
||||
{
|
||||
@ -296,9 +312,6 @@ namespace etl
|
||||
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -314,9 +327,6 @@ namespace etl
|
||||
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -332,9 +342,6 @@ namespace etl
|
||||
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -349,6 +356,7 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases an element.
|
||||
|
||||
@ -284,6 +284,37 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
std::pair<iterator, bool> emplace(Args && ... args)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_set_full));
|
||||
|
||||
std::pair<iterator, bool> result;
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(std::forward<Args>(args)...);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (*i_element != *pvalue)))
|
||||
{
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
result = refset_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Destroy it.
|
||||
pvalue->~value_type();
|
||||
storage.release(pvalue);
|
||||
result = std::pair<iterator, bool>(end(), false);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
std::pair<iterator, bool> emplace(const T1& value1)
|
||||
{
|
||||
@ -314,9 +345,6 @@ namespace etl
|
||||
return result;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -347,9 +375,6 @@ namespace etl
|
||||
return result;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -380,9 +405,6 @@ namespace etl
|
||||
return result;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -412,6 +434,7 @@ namespace etl
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases an element.
|
||||
|
||||
@ -642,6 +642,19 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list..
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
void emplace_front(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
|
||||
#endif
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(std::forward<Args>(args)...);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
void emplace_front(const T1& value1)
|
||||
{
|
||||
@ -654,9 +667,6 @@ namespace etl
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list..
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace_front(const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -669,9 +679,6 @@ namespace etl
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)
|
||||
{
|
||||
@ -684,9 +691,6 @@ namespace etl
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)
|
||||
{
|
||||
@ -698,6 +702,7 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(start_node, *p_data_node);
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Removes a value from the front of the forward_list.
|
||||
@ -778,6 +783,20 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the forward_list after the specified position.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
iterator emplace_after(iterator position, Args && ... args)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(forward_list_full));
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(std::forward<Args>(args)...);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node_after(*position.p_node, *p_data_node);
|
||||
|
||||
return iterator(p_data_node);
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
iterator emplace_after(iterator position, const T1& value1)
|
||||
{
|
||||
@ -791,9 +810,6 @@ namespace etl
|
||||
return iterator(p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the forward_list after the specified position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
iterator emplace_after(iterator position, const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -807,9 +823,6 @@ namespace etl
|
||||
return iterator(p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the forward_list after the specified position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
iterator emplace_after(iterator position, const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -823,9 +836,6 @@ namespace etl
|
||||
return iterator(p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the forward_list after the specified position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
iterator emplace_after(iterator position, const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -838,6 +848,7 @@ namespace etl
|
||||
|
||||
return iterator(p_data_node);
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Inserts 'n' copies of a value to the forward_list after the specified position.
|
||||
|
||||
@ -846,6 +846,21 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list..
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
void emplace_front(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
#endif
|
||||
ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool));
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(std::forward<Args>(args)...);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(get_head(), *p_data_node);
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
void emplace_front(const T1& value1)
|
||||
{
|
||||
@ -860,9 +875,6 @@ namespace etl
|
||||
insert_node(get_head(), *p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the front of the list..
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace_front(const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -877,9 +889,6 @@ namespace etl
|
||||
insert_node(get_head(), *p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)
|
||||
{
|
||||
@ -894,9 +903,6 @@ namespace etl
|
||||
insert_node(get_head(), *p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)
|
||||
{
|
||||
@ -910,6 +916,7 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(get_head(), *p_data_node);
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Removes a value from the front of the list.
|
||||
@ -937,6 +944,21 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the back of the list..
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
void emplace_back(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
#endif
|
||||
ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool));
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(std::forward<Args>(args)...);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
void emplace_back(const T1& value1)
|
||||
{
|
||||
@ -951,9 +973,6 @@ namespace etl
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the back of the list..
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace_back(const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -968,9 +987,6 @@ namespace etl
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the back of the list..
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace_back(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -985,9 +1001,6 @@ namespace etl
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the back of the list..
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace_back(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -1001,6 +1014,7 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(terminal_node, *p_data_node);
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Removes a value from the back of the list.
|
||||
@ -1030,6 +1044,21 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the list at the specified position.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
iterator emplace(iterator position, Args && ... args)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(list_full));
|
||||
ETL_ASSERT(p_node_pool != nullptr, ETL_ERROR(list_no_pool));
|
||||
|
||||
data_node_t* p_data_node = p_node_pool->allocate<data_node_t>();
|
||||
::new (&(p_data_node->value)) T(std::forward<Args>(args)...);
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
insert_node(*position.p_node, *p_data_node);
|
||||
|
||||
return iterator(*p_data_node);
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
iterator emplace(iterator position, const T1& value1)
|
||||
{
|
||||
@ -1044,9 +1073,6 @@ namespace etl
|
||||
return iterator(*p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the list at the specified position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
iterator emplace(iterator position, const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -1061,9 +1087,6 @@ namespace etl
|
||||
return iterator(*p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the list at the specified position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
iterator emplace(iterator position, const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -1078,9 +1101,6 @@ namespace etl
|
||||
return iterator(*p_data_node);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the list at the specified position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
iterator emplace(iterator position, const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -1094,6 +1114,7 @@ namespace etl
|
||||
|
||||
return iterator(*p_data_node);
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Inserts 'n' copies of a value to the list at the specified position.
|
||||
|
||||
@ -173,11 +173,6 @@ namespace etl
|
||||
return p;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Allocate storage for an object from the pool and create with 2 parameters.
|
||||
/// If asserts or exceptions are enabled and there are no more free items an
|
||||
/// etl::pool_no_allocation if thrown, otherwise a nullptr is returned.
|
||||
//*************************************************************************
|
||||
template <typename T, typename T1, typename T2>
|
||||
T* create(const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -191,11 +186,6 @@ namespace etl
|
||||
return p;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Allocate storage for an object from the pool and create with 3 parameters.
|
||||
/// If asserts or exceptions are enabled and there are no more free items an
|
||||
/// etl::pool_no_allocation if thrown, otherwise a nullptr is returned.
|
||||
//*************************************************************************
|
||||
template <typename T, typename T1, typename T2, typename T3>
|
||||
T* create(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -209,11 +199,6 @@ namespace etl
|
||||
return p;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Allocate storage for an object from the pool and create with 4 parameters.
|
||||
/// If asserts or exceptions are enabled and there are no more free items an
|
||||
/// etl::pool_no_allocation if thrown, otherwise a nullptr is returned.
|
||||
//*************************************************************************
|
||||
template <typename T, typename T1, typename T2, typename T3, typename T4>
|
||||
T* create(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
|
||||
@ -174,6 +174,18 @@ namespace etl
|
||||
/// is the priority queue is already full.
|
||||
///\param value The value to push to the queue.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
void emplace(Args && ... args)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(etl::priority_queue_full));
|
||||
|
||||
// Put element at end
|
||||
container.emplace_back(std::forward<Args>(args)...);
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
void emplace(const T1& value1)
|
||||
{
|
||||
@ -185,12 +197,6 @@ namespace etl
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the queue.
|
||||
/// If asserts or exceptions are enabled, throws an etl::priority_queue_full
|
||||
/// is the priority queue is already full.
|
||||
///\param value The value to push to the queue.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace(const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -202,12 +208,6 @@ namespace etl
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the queue.
|
||||
/// If asserts or exceptions are enabled, throws an etl::priority_queue_full
|
||||
/// is the priority queue is already full.
|
||||
///\param value The value to push to the queue.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -219,12 +219,6 @@ namespace etl
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the queue.
|
||||
/// If asserts or exceptions are enabled, throws an etl::priority_queue_full
|
||||
/// is the priority queue is already full.
|
||||
///\param value The value to push to the queue.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -235,6 +229,7 @@ namespace etl
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Assigns values to the priority queue.
|
||||
|
||||
@ -321,6 +321,17 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
|
||||
///\param value The value to use to construct the item to push to the queue.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
void emplace(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(queue_full));
|
||||
#endif
|
||||
::new (&p_buffer[in]) T(std::forward<Args>(args)...);
|
||||
add_in();
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
void emplace(const T1& value1)
|
||||
{
|
||||
@ -331,11 +342,6 @@ namespace etl
|
||||
add_in();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructs a value in the queue 'in place'.
|
||||
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
|
||||
///\param value The value to use to construct the item to push to the queue.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace(const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -346,11 +352,6 @@ namespace etl
|
||||
add_in();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructs a value in the queue 'in place'.
|
||||
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
|
||||
///\param value The value to use to construct the item to push to the queue.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -361,11 +362,6 @@ namespace etl
|
||||
add_in();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructs a value in the queue 'in place'.
|
||||
/// If asserts or exceptions are enabled, throws an etl::queue_full if the queue if already full.
|
||||
///\param value The value to use to construct the item to push to the queue.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -375,6 +371,7 @@ namespace etl
|
||||
::new (&p_buffer[in]) T(value1, value2, value3, value4);
|
||||
add_in();
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Clears the queue to the empty state.
|
||||
|
||||
@ -267,6 +267,17 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.
|
||||
///\param value The value to push to the stack.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
void emplace(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(!full(), ETL_ERROR(stack_full));
|
||||
#endif
|
||||
base_t::add_in();
|
||||
::new (&p_buffer[top_index]) T(std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
void emplace(const T1& value1)
|
||||
{
|
||||
@ -277,11 +288,6 @@ namespace etl
|
||||
::new (&p_buffer[top_index]) T(value1);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructs a value in the stack place'.
|
||||
/// If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.
|
||||
///\param value The value to push to the stack.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace(const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -292,11 +298,6 @@ namespace etl
|
||||
::new (&p_buffer[top_index]) T(value1, value2);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructs a value in the stack place'.
|
||||
/// If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.
|
||||
///\param value The value to push to the stack.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void emplace(const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -307,11 +308,6 @@ namespace etl
|
||||
::new (&p_buffer[top_index]) T(value1, value2, value3);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructs a value in the stack place'.
|
||||
/// If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.
|
||||
///\param value The value to push to the stack.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -321,6 +317,7 @@ namespace etl
|
||||
base_t::add_in();
|
||||
::new (&p_buffer[top_index]) T(value1, value2, value3, value4);
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets a const reference to the value at the top of the stack.<br>
|
||||
|
||||
@ -416,6 +416,18 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
void emplace_back(Args && ... args)
|
||||
{
|
||||
#if defined(ETL_CHECK_PUSH_POP)
|
||||
ETL_ASSERT(size() != CAPACITY, ETL_ERROR(vector_full));
|
||||
#endif
|
||||
::new (p_end) T(std::forward<Args>(args)...);
|
||||
++p_end;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
void emplace_back(const T1& value1)
|
||||
{
|
||||
@ -427,11 +439,6 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Constructs a value at the end of the vector.
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
|
||||
///\param value The value to add.
|
||||
//*********************************************************************
|
||||
template <typename T1, typename T2>
|
||||
void emplace_back(const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -443,11 +450,6 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Constructs a value at the end of the vector.
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
|
||||
///\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)
|
||||
{
|
||||
@ -459,11 +461,6 @@ namespace etl
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Constructs a value at the end of the vector.
|
||||
/// If asserts or exceptions are enabled, emits vector_full if the vector is already full.
|
||||
///\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)
|
||||
{
|
||||
@ -474,6 +471,7 @@ namespace etl
|
||||
++p_end;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*************************************************************************
|
||||
/// Removes an element from the end of the vector.
|
||||
@ -514,6 +512,32 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the vextor at the specified position.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
template <typename ... Args>
|
||||
iterator emplace(iterator position, Args && ... args)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(vector_full));
|
||||
|
||||
void* p;
|
||||
|
||||
if (position == end())
|
||||
{
|
||||
p = p_end++;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
}
|
||||
else
|
||||
{
|
||||
p = etl::addressof(*position);
|
||||
create_back(back());
|
||||
std::copy_backward(position, p_end - 1, p_end);
|
||||
(*position).~T();
|
||||
}
|
||||
|
||||
::new (p) T(std::forward<Args>(args)...);
|
||||
|
||||
return position;
|
||||
}
|
||||
#else
|
||||
template <typename T1>
|
||||
iterator emplace(iterator position, const T1& value1)
|
||||
{
|
||||
@ -539,9 +563,6 @@ namespace etl
|
||||
return position;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the vextor at the specified position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
iterator emplace(iterator position, const T1& value1, const T2& value2)
|
||||
{
|
||||
@ -567,9 +588,6 @@ namespace etl
|
||||
return position;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the vextor at the specified position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
iterator emplace(iterator position, const T1& value1, const T2& value2, const T3& value3)
|
||||
{
|
||||
@ -595,9 +613,6 @@ namespace etl
|
||||
return position;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the vextor at the specified position.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
iterator emplace(iterator position, const T1& value1, const T2& value2, const T3& value3, const T4& value4)
|
||||
{
|
||||
@ -622,6 +637,7 @@ namespace etl
|
||||
|
||||
return position;
|
||||
}
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts 'n' values to the vector.
|
||||
|
||||
@ -46,7 +46,6 @@ set(TEST_SOURCE_FILES
|
||||
test_enum_type.cpp
|
||||
test_error_handler.cpp
|
||||
test_exception.cpp
|
||||
# test_factory.cpp
|
||||
test_fixed_iterator.cpp
|
||||
test_flat_map.cpp
|
||||
test_flat_multimap.cpp
|
||||
@ -119,6 +118,8 @@ set(TEST_SOURCE_FILES
|
||||
test_xor_checksum.cpp
|
||||
test_xor_rotate_checksum.cpp
|
||||
|
||||
${CMAKE_SOURCE_DIR}/src/crc16_modbus.cpp
|
||||
|
||||
# Compile the source level ecl_timer here as test has provided a ecl_user.h file
|
||||
${PROJECT_SOURCE_DIR}/../src/c/ecl_timer.c
|
||||
)
|
||||
|
||||
@ -571,6 +571,106 @@ namespace
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back_multiple)
|
||||
{
|
||||
class Data
|
||||
{
|
||||
public:
|
||||
std::string a;
|
||||
size_t b;
|
||||
double c;
|
||||
const char *d;
|
||||
Data(std::string w) : a(w){}
|
||||
Data(std::string w, size_t x) : a(w), b(x){}
|
||||
Data(std::string w, size_t x, double y) : a(w), b(x), c(y){}
|
||||
Data(std::string w, size_t x, double y, const char *z) : a(w), b(x), c(y){}
|
||||
bool operator == (const Data &other) const
|
||||
{
|
||||
return (a == other.a) && (b == other.b) && (c == other.c) && (d == other.d);
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<Data> compare_data;
|
||||
etl::vector<Data, SIZE * 3> data;
|
||||
|
||||
std::string s;
|
||||
for (size_t i = 0; i < SIZE; ++i)
|
||||
{
|
||||
s += "x";
|
||||
|
||||
// 4 arguments
|
||||
compare_data.emplace_back(s, i, static_cast<double>(i) + 0.1234, "emplace_back");
|
||||
data.emplace_back(s, i, static_cast<double>(i) + 0.1234, "emplace_back");
|
||||
|
||||
// 3 arguments
|
||||
compare_data.emplace_back(s, i, static_cast<double>(i) + 0.1234);
|
||||
data.emplace_back(s, i, static_cast<double>(i) + 0.1234);
|
||||
|
||||
// 2 arguments
|
||||
compare_data.emplace_back(s, i);
|
||||
data.emplace_back(s, i);
|
||||
|
||||
// 1 argument
|
||||
compare_data.emplace_back(s);
|
||||
data.emplace_back(s);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(compare_data.size(), data.size());
|
||||
|
||||
const bool is_equal = std::equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
|
||||
CHECK(is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// The C++11 variadic version uses non-const rvalue references so has the ability
|
||||
// to emplace non-const reference members, the pre-C++11 const reference overloads
|
||||
// does not have the ability to pass const reference parameters to non-const
|
||||
// constructor parameters (like the members in Data below)
|
||||
// So this is only tested on C++11 onwards
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_back_non_const_references)
|
||||
{
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
class Data
|
||||
{
|
||||
public:
|
||||
std::string &a;
|
||||
size_t &b;
|
||||
double &c;
|
||||
const char *d;
|
||||
Data(std::string &w, size_t &x, double &y, const char *z) : a(w), b(x), c(y), d(z){}
|
||||
bool operator == (const Data &other) const
|
||||
{
|
||||
return (a == other.a) && (b == other.b) && (c == other.c) && (d == other.d);
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<Data> compare_data;
|
||||
etl::vector<Data, SIZE * 3> data;
|
||||
|
||||
std::string a = "test_test_test";
|
||||
size_t b = 9999;
|
||||
double c = 123.456;
|
||||
const char *d = "abcdefghijklmnopqrstuvwxyz";
|
||||
for (size_t i = 0; i < SIZE; ++i)
|
||||
{
|
||||
data.emplace_back(a, b, c, d);
|
||||
compare_data.emplace_back(a, b, c, d);
|
||||
}
|
||||
|
||||
CHECK_EQUAL(compare_data.size(), data.size());
|
||||
|
||||
const bool is_equal = std::equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
|
||||
CHECK(is_equal);
|
||||
#endif // ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_pop_back)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user