mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-18 09:56:07 +08:00
Merge branch 'feature/emplace' into development
This commit is contained in:
commit
d93e60f273
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library
|
||||
version=10.15.0
|
||||
version=10.16.0
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
sentence=A C++ template library tailored for embedded systems.
|
||||
|
||||
188
src/flat_map.h
188
src/flat_map.h
@ -336,6 +336,194 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
std::pair<iterator, bool> emplace(const value_type& value)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_map_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value);
|
||||
|
||||
iterator i_element = lower_bound(value.first);
|
||||
|
||||
std::pair<iterator, bool> result(i_element, false);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (i_element->first != value.first)))
|
||||
{
|
||||
++construct_count;
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
pvalue->~value_type();
|
||||
storage.release(pvalue);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const mapped_type& value)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_map_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(key, value);
|
||||
|
||||
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)))
|
||||
{
|
||||
++construct_count;
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
pvalue->~value_type();
|
||||
storage.release(pvalue);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
template <typename T1>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1)
|
||||
{
|
||||
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(value1);
|
||||
|
||||
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)))
|
||||
{
|
||||
++construct_count;
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
pvalue->~value_type();
|
||||
storage.release(pvalue);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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(value1, value2);
|
||||
|
||||
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)))
|
||||
{
|
||||
++construct_count;
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
pvalue->~value_type();
|
||||
storage.release(pvalue);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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(value1, value2, value3);
|
||||
|
||||
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)))
|
||||
{
|
||||
++construct_count;
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
pvalue->~value_type();
|
||||
storage.release(pvalue);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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(value1, value2, value3, value4);
|
||||
|
||||
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)))
|
||||
{
|
||||
++construct_count;
|
||||
result = refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
pvalue->~value_type();
|
||||
storage.release(pvalue);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases an element.
|
||||
///\param key The key to erase.
|
||||
|
||||
@ -264,7 +264,7 @@ namespace etl
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a value to the flast_multi.
|
||||
/// If asserts or exceptions are enabled, emits flat_map_full if the flat_map is already full.
|
||||
/// If asserts or exceptions are enabled, emits flat_multimap_full if the flat_map is already full.
|
||||
///\param position The position to insert at.
|
||||
///\param value The value to insert.
|
||||
//*********************************************************************
|
||||
@ -289,6 +289,110 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
std::pair<iterator, bool> emplace(const value_type& value)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value);
|
||||
iterator i_element = lower_bound(value.first);
|
||||
++construct_count;
|
||||
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const mapped_type& value)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multimap_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(key, value);
|
||||
iterator i_element = lower_bound(key);
|
||||
++construct_count;
|
||||
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
template <typename T1>
|
||||
std::pair<iterator, bool> emplace(const key_type& key, const T1& value1)
|
||||
{
|
||||
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(value1);
|
||||
iterator i_element = lower_bound(key);
|
||||
++construct_count;
|
||||
|
||||
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)
|
||||
{
|
||||
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(value1, value2);
|
||||
iterator i_element = lower_bound(key);
|
||||
++construct_count;
|
||||
|
||||
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)
|
||||
{
|
||||
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(value1, value2, value3);
|
||||
iterator i_element = lower_bound(key);
|
||||
++construct_count;
|
||||
|
||||
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)
|
||||
{
|
||||
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(value1, value2, value3, value4);
|
||||
iterator i_element = lower_bound(key);
|
||||
++construct_count;
|
||||
|
||||
return refmap_t::insert_at(i_element, *pvalue);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases an element.
|
||||
///\param key The key to erase.
|
||||
|
||||
@ -230,8 +230,6 @@ namespace etl
|
||||
|
||||
iterator i_element = std::lower_bound(begin(), end(), value, TKeyCompare());
|
||||
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
|
||||
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value);
|
||||
++construct_count;
|
||||
@ -267,6 +265,96 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
template <typename T1>
|
||||
std::pair<iterator, bool> emplace(parameter_t value)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
++construct_count;
|
||||
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
template <typename T1>
|
||||
std::pair<iterator, bool> emplace(const T1& value1)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value1);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
++construct_count;
|
||||
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)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value1, value2);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
++construct_count;
|
||||
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)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value1, value2, value3);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
++construct_count;
|
||||
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)
|
||||
{
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
|
||||
|
||||
// Create it.
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value1, value2, value3, value4);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
++construct_count;
|
||||
return std::pair<iterator, bool>(refset_t::insert_at(i_element, *pvalue));
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases an element.
|
||||
///\param key The key to erase.
|
||||
|
||||
164
src/flat_set.h
164
src/flat_set.h
@ -269,6 +269,170 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
std::pair<iterator, bool> emplace(parameter_t value)
|
||||
{
|
||||
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(value);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (*i_element != *pvalue)))
|
||||
{
|
||||
++construct_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;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
template <typename T1>
|
||||
std::pair<iterator, bool> emplace(const T1& value1)
|
||||
{
|
||||
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(value1);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (*i_element != *pvalue)))
|
||||
{
|
||||
++construct_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;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the set.
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
std::pair<iterator, bool> emplace(const T1& value1, const T2& value2)
|
||||
{
|
||||
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(value1, value2);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (*i_element != *pvalue)))
|
||||
{
|
||||
++construct_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;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)
|
||||
{
|
||||
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(value1, value2, value3);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (*i_element != *pvalue)))
|
||||
{
|
||||
++construct_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;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// 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)
|
||||
{
|
||||
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(value1, value2, value3, value4);
|
||||
|
||||
iterator i_element = lower_bound(*pvalue);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end() || (*i_element != *pvalue)))
|
||||
{
|
||||
++construct_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;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Erases an element.
|
||||
///\param key The key to erase.
|
||||
|
||||
@ -1,3 +1,23 @@
|
||||
===============================================================================
|
||||
10.16.0
|
||||
Added emplace member functions to flat_map, flat_multimap, flat_set and flat_multiset
|
||||
|
||||
===============================================================================
|
||||
10.15.0
|
||||
Added protected destructors to FSM & message_timer and code to message router packet destructor to choose correct method of destruction.
|
||||
|
||||
===============================================================================
|
||||
10.14.0
|
||||
Added variant_pool generator.
|
||||
|
||||
===============================================================================
|
||||
10.13.0
|
||||
There was no version 10.13.0
|
||||
|
||||
===============================================================================
|
||||
10.12.0
|
||||
Re-written to avoid 'undefined behavior' by allowing containers to be polymorphic or not base on a compile time macro.
|
||||
|
||||
===============================================================================
|
||||
10.11.2
|
||||
GCC compatibility changes.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -64,6 +64,113 @@ namespace
|
||||
typedef std::map<int, DC> Compare_DataDC;
|
||||
typedef std::map<int, NDC> Compare_DataNDC;
|
||||
|
||||
struct D1
|
||||
{
|
||||
D1(const std::string& a_)
|
||||
: a(a_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
};
|
||||
|
||||
struct D2
|
||||
{
|
||||
D2(const std::string& a_, const std::string& b_)
|
||||
: a(a_),
|
||||
b(b_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
};
|
||||
|
||||
struct D3
|
||||
{
|
||||
D3(const std::string& a_, const std::string& b_, const std::string& c_)
|
||||
: a(a_),
|
||||
b(b_),
|
||||
c(c_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
std::string c;
|
||||
};
|
||||
|
||||
struct D4
|
||||
{
|
||||
D4(const std::string& a_, const std::string& b_, const std::string& c_, const std::string& d_)
|
||||
: a(a_),
|
||||
b(b_),
|
||||
c(c_),
|
||||
d(d_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
std::string c;
|
||||
std::string d;
|
||||
};
|
||||
|
||||
bool operator == (const D1& lhs, const D1& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a);
|
||||
}
|
||||
|
||||
bool operator == (const D2& lhs, const D2& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b);
|
||||
}
|
||||
|
||||
bool operator == (const D3& lhs, const D3& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c);
|
||||
}
|
||||
|
||||
bool operator == (const D4& lhs, const D4& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d);
|
||||
}
|
||||
|
||||
bool operator != (const D1& lhs, const D1& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator != (const D2& lhs, const D2& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator != (const D3& lhs, const D3& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator != (const D4& lhs, const D4& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
typedef std::pair<const int, D1> Element1;
|
||||
typedef std::pair<const int, D2> Element2;
|
||||
typedef std::pair<const int, D3> Element3;
|
||||
typedef std::pair<const int, D4> Element4;
|
||||
|
||||
typedef etl::flat_map<int, D1, SIZE> Data1;
|
||||
typedef etl::flat_map<int, D2, SIZE> Data2;
|
||||
typedef etl::flat_map<int, D3, SIZE> Data3;
|
||||
typedef etl::flat_map<int, D4, SIZE> Data4;
|
||||
|
||||
typedef std::map<int, D1> Compare1;
|
||||
typedef std::map<int, D2> Compare2;
|
||||
typedef std::map<int, D3> Compare3;
|
||||
typedef std::map<int, D4> Compare4;
|
||||
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
bool Check_Equal(T1 begin1, T1 end1, T2 begin2)
|
||||
@ -165,24 +272,6 @@ namespace
|
||||
|
||||
std::vector<ElementInt> int_data;
|
||||
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
bool Check_Equal(T1 begin1, T1 end1, T2 begin2)
|
||||
{
|
||||
while (begin1 != end1)
|
||||
{
|
||||
if ((begin1->first != begin2->first) || (begin1->second != begin2->second))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
++begin1;
|
||||
++begin2;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
struct SetupFixture
|
||||
{
|
||||
@ -606,6 +695,186 @@ namespace
|
||||
CHECK_THROW(data.insert(excess_data.begin(), excess_data.end()), etl::flat_map_full);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value1)
|
||||
{
|
||||
Compare1 compare;
|
||||
Data1 data;
|
||||
|
||||
std::pair<Data1::iterator, bool> result;
|
||||
|
||||
result = data.emplace(0, "0");
|
||||
compare.emplace(0, D1("0"));
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element1(0, D1("0")));
|
||||
|
||||
result = data.emplace(std::make_pair(2, D1("2")));
|
||||
compare.emplace(std::make_pair(2, D1("2")));
|
||||
|
||||
isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element1(2, D1("2")));
|
||||
|
||||
result = data.emplace(1, "1");
|
||||
compare.emplace(1, D1("1"));
|
||||
|
||||
isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element1(1, D1("1")));
|
||||
|
||||
result = data.emplace(1, D1("1"));
|
||||
CHECK(!result.second);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value2)
|
||||
{
|
||||
Compare2 compare;
|
||||
Data2 data;
|
||||
|
||||
std::pair<Data2::iterator, bool> result;
|
||||
|
||||
result = data.emplace(0, "0", "1");
|
||||
compare.emplace(0, D2("0", "1"));
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element2(0, D2("0", "1")));
|
||||
|
||||
result = data.emplace(std::make_pair(2, D2("2", "3")));
|
||||
compare.emplace(std::make_pair(2, D2("2", "3")));
|
||||
|
||||
isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element2(2, D2("2", "3")));
|
||||
|
||||
result = data.emplace(1, D2("1", "2"));
|
||||
compare.emplace(1, D2("1", "2"));
|
||||
|
||||
isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element2(1, D2("1", "2")));
|
||||
|
||||
result = data.emplace(1, D2("1", "2"));
|
||||
CHECK(!result.second);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value3)
|
||||
{
|
||||
Compare3 compare;
|
||||
Data3 data;
|
||||
|
||||
std::pair<Data3::iterator, bool> result;
|
||||
|
||||
result = data.emplace(0, "0", "1", "2");
|
||||
compare.emplace(0, D3("0", "1", "2"));
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element3(0, D3("0", "1", "2")));
|
||||
|
||||
result = data.emplace(std::make_pair(2, D3("2", "3", "4")));
|
||||
compare.emplace(std::make_pair(2, D3("2", "3", "4")));
|
||||
|
||||
isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element3(2, D3("2", "3", "4")));
|
||||
|
||||
result = data.emplace(1, D3("1", "2", "3"));
|
||||
compare.emplace(1, D3("1", "2", "3"));
|
||||
|
||||
isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element3(1, D3("1", "2", "3")));
|
||||
|
||||
result = data.emplace(1, D3("1", "2", "3"));
|
||||
CHECK(!result.second);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value4)
|
||||
{
|
||||
Compare4 compare;
|
||||
Data4 data;
|
||||
|
||||
std::pair<Data4::iterator, bool> result;
|
||||
|
||||
result = data.emplace(0, "0", "1", "2", "3");
|
||||
compare.emplace(0, D4("0", "1", "2", "3"));
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element4(0, D4("0", "1", "2", "3")));
|
||||
|
||||
result = data.emplace(std::make_pair(2, D4("2", "3", "4", "5")));
|
||||
compare.emplace(std::make_pair(2, D4("2", "3", "4", "5")));
|
||||
|
||||
isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element4(2, D4("2", "3", "4", "5")));
|
||||
|
||||
result = data.emplace(1, D4("1", "2", "3", "4"));
|
||||
compare.emplace(1, D4("1", "2", "3", "4"));
|
||||
|
||||
isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
CHECK(result.second);
|
||||
CHECK(*result.first == Element4(1, D4("1", "2", "3", "4")));
|
||||
|
||||
result = data.emplace(1, D4("1", "2", "3", "4"));
|
||||
CHECK(!result.second);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_erase_key)
|
||||
{
|
||||
|
||||
@ -90,6 +90,113 @@ namespace
|
||||
|
||||
std::vector<ElementInt> int_data;
|
||||
|
||||
struct D1
|
||||
{
|
||||
D1(const std::string& a_)
|
||||
: a(a_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
};
|
||||
|
||||
struct D2
|
||||
{
|
||||
D2(const std::string& a_, const std::string& b_)
|
||||
: a(a_),
|
||||
b(b_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
};
|
||||
|
||||
struct D3
|
||||
{
|
||||
D3(const std::string& a_, const std::string& b_, const std::string& c_)
|
||||
: a(a_),
|
||||
b(b_),
|
||||
c(c_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
std::string c;
|
||||
};
|
||||
|
||||
struct D4
|
||||
{
|
||||
D4(const std::string& a_, const std::string& b_, const std::string& c_, const std::string& d_)
|
||||
: a(a_),
|
||||
b(b_),
|
||||
c(c_),
|
||||
d(d_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
std::string c;
|
||||
std::string d;
|
||||
};
|
||||
|
||||
bool operator == (const D1& lhs, const D1& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a);
|
||||
}
|
||||
|
||||
bool operator == (const D2& lhs, const D2& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b);
|
||||
}
|
||||
|
||||
bool operator == (const D3& lhs, const D3& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c);
|
||||
}
|
||||
|
||||
bool operator == (const D4& lhs, const D4& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d);
|
||||
}
|
||||
|
||||
bool operator != (const D1& lhs, const D1& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator != (const D2& lhs, const D2& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator != (const D3& lhs, const D3& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator != (const D4& lhs, const D4& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
typedef std::pair<const int, D1> Element1;
|
||||
typedef std::pair<const int, D2> Element2;
|
||||
typedef std::pair<const int, D3> Element3;
|
||||
typedef std::pair<const int, D4> Element4;
|
||||
|
||||
typedef etl::flat_multimap<int, D1, SIZE> Data1;
|
||||
typedef etl::flat_multimap<int, D2, SIZE> Data2;
|
||||
typedef etl::flat_multimap<int, D3, SIZE> Data3;
|
||||
typedef etl::flat_multimap<int, D4, SIZE> Data4;
|
||||
|
||||
typedef std::multimap<int, D1> Compare1;
|
||||
typedef std::multimap<int, D2> Compare2;
|
||||
typedef std::multimap<int, D3> Compare3;
|
||||
typedef std::multimap<int, D4> Compare4;
|
||||
|
||||
//*************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
bool Check_Equal(T1 begin1, T1 end1, T2 begin2)
|
||||
@ -436,6 +543,142 @@ namespace
|
||||
CHECK(std::is_sorted(data.begin(), data.end()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value1)
|
||||
{
|
||||
Compare1 compare;
|
||||
Data1 data;
|
||||
|
||||
data.emplace(0, "0");
|
||||
compare.emplace(0, D1("0"));
|
||||
|
||||
data.emplace(1, D1("1"));
|
||||
compare.emplace(1, D1("1"));
|
||||
|
||||
data.emplace(std::make_pair(2, D1("2")));
|
||||
compare.emplace(std::make_pair(2, D1("2")));
|
||||
|
||||
// Do it again.
|
||||
data.emplace(0, "0");
|
||||
compare.emplace(0, D1("0"));
|
||||
|
||||
data.emplace(1, D1("1"));
|
||||
compare.emplace(1, D1("1"));
|
||||
|
||||
data.emplace(std::make_pair(2, D1("2")));
|
||||
compare.emplace(std::make_pair(2, D1("2")));
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value2)
|
||||
{
|
||||
Compare2 compare;
|
||||
Data2 data;
|
||||
|
||||
data.emplace(0, "0", "1");
|
||||
compare.emplace(0, D2("0", "1"));
|
||||
|
||||
data.emplace(1, D2("1", "2"));
|
||||
compare.emplace(1, D2("1", "2"));
|
||||
|
||||
data.emplace(std::make_pair(2, D2("2", "3")));
|
||||
compare.emplace(std::make_pair(2, D2("2", "3")));
|
||||
|
||||
// Do it again.
|
||||
data.emplace(0, "0", "1");
|
||||
compare.emplace(0, D2("0", "1"));
|
||||
|
||||
data.emplace(1, D2("1", "2"));
|
||||
compare.emplace(1, D2("1", "2"));
|
||||
|
||||
data.emplace(std::make_pair(2, D2("2", "3")));
|
||||
compare.emplace(std::make_pair(2, D2("2", "3")));
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value3)
|
||||
{
|
||||
Compare3 compare;
|
||||
Data3 data;
|
||||
|
||||
data.emplace(0, "0", "1", "2");
|
||||
compare.emplace(0, D3("0", "1", "2"));
|
||||
|
||||
data.emplace(1, D3("1", "2", "3"));
|
||||
compare.emplace(1, D3("1", "2", "3"));
|
||||
|
||||
data.emplace(std::make_pair(2, D3("2", "3", "4")));
|
||||
compare.emplace(std::make_pair(2, D3("2", "3", "4")));
|
||||
|
||||
// Do it again.
|
||||
data.emplace(0, "0", "1", "2");
|
||||
compare.emplace(0, D3("0", "1", "2"));
|
||||
|
||||
data.emplace(1, D3("1", "2", "3"));
|
||||
compare.emplace(1, D3("1", "2", "3"));
|
||||
|
||||
data.emplace(std::make_pair(2, D3("2", "3", "4")));
|
||||
compare.emplace(std::make_pair(2, D3("2", "3", "4")));
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value4)
|
||||
{
|
||||
Compare4 compare;
|
||||
Data4 data;
|
||||
|
||||
data.emplace(0, "0", "1", "2", "3");
|
||||
compare.emplace(0, D4("0", "1", "2", "3"));
|
||||
|
||||
data.emplace(1, D4("1", "2", "3", "4"));
|
||||
compare.emplace(1, D4("1", "2", "3", "4"));
|
||||
|
||||
data.emplace(std::make_pair(2, D4("2", "3", "4", "5")));
|
||||
compare.emplace(std::make_pair(2, D4("2", "3", "4", "5")));
|
||||
|
||||
// Do it again.
|
||||
data.emplace(0, "0", "1", "2", "3");
|
||||
compare.emplace(0, D4("0", "1", "2", "3"));
|
||||
|
||||
data.emplace(1, D4("1", "2", "3", "4"));
|
||||
compare.emplace(1, D4("1", "2", "3", "4"));
|
||||
|
||||
data.emplace(std::make_pair(2, D4("2", "3", "4", "5")));
|
||||
compare.emplace(std::make_pair(2, D4("2", "3", "4", "5")));
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_erase_key)
|
||||
{
|
||||
|
||||
@ -56,6 +56,109 @@ namespace
|
||||
typedef std::multiset<DC> Compare_DataDC;
|
||||
typedef std::multiset<NDC> Compare_DataNDC;
|
||||
|
||||
struct D1
|
||||
{
|
||||
D1(const std::string& a_)
|
||||
: a(a_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
};
|
||||
|
||||
struct D2
|
||||
{
|
||||
D2(const std::string& a_, const std::string& b_)
|
||||
: a(a_),
|
||||
b(b_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
};
|
||||
|
||||
struct D3
|
||||
{
|
||||
D3(const std::string& a_, const std::string& b_, const std::string& c_)
|
||||
: a(a_),
|
||||
b(b_),
|
||||
c(c_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
std::string c;
|
||||
};
|
||||
|
||||
struct D4
|
||||
{
|
||||
D4(const std::string& a_, const std::string& b_, const std::string& c_, const std::string& d_)
|
||||
: a(a_),
|
||||
b(b_),
|
||||
c(c_),
|
||||
d(d_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
std::string c;
|
||||
std::string d;
|
||||
};
|
||||
|
||||
bool operator == (const D1& lhs, const D1& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a);
|
||||
}
|
||||
|
||||
bool operator == (const D2& lhs, const D2& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b);
|
||||
}
|
||||
|
||||
bool operator == (const D3& lhs, const D3& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c);
|
||||
}
|
||||
|
||||
bool operator == (const D4& lhs, const D4& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d);
|
||||
}
|
||||
|
||||
bool operator < (const D1& lhs, const D1& rhs)
|
||||
{
|
||||
return (lhs.a < rhs.a);
|
||||
}
|
||||
|
||||
bool operator < (const D2& lhs, const D2& rhs)
|
||||
{
|
||||
return (lhs.a < rhs.a) && (lhs.b < rhs.b);
|
||||
}
|
||||
|
||||
bool operator < (const D3& lhs, const D3& rhs)
|
||||
{
|
||||
return (lhs.a < rhs.a) && (lhs.b < rhs.b) && (lhs.c < rhs.c);
|
||||
}
|
||||
|
||||
bool operator < (const D4& lhs, const D4& rhs)
|
||||
{
|
||||
return (lhs.a < rhs.a) && (lhs.b < rhs.b) && (lhs.c < rhs.c) && (lhs.d < rhs.d);
|
||||
}
|
||||
|
||||
typedef etl::flat_multiset<D1, SIZE> Data1;
|
||||
typedef etl::flat_multiset<D2, SIZE> Data2;
|
||||
typedef etl::flat_multiset<D3, SIZE> Data3;
|
||||
typedef etl::flat_multiset<D4, SIZE> Data4;
|
||||
|
||||
typedef std::multiset<D1> Compare1;
|
||||
typedef std::multiset<D2> Compare2;
|
||||
typedef std::multiset<D3> Compare3;
|
||||
typedef std::multiset<D4> Compare4;
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
std::ostream& operator <<(std::ostream& os, DataNDC::iterator itr)
|
||||
{
|
||||
@ -393,6 +496,142 @@ namespace
|
||||
CHECK(std::is_sorted(data.begin(), data.end()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value1)
|
||||
{
|
||||
Compare1 compare;
|
||||
Data1 data;
|
||||
|
||||
data.emplace("0");
|
||||
compare.emplace("0");
|
||||
|
||||
data.emplace("1");
|
||||
compare.emplace("1");
|
||||
|
||||
data.emplace("2");
|
||||
compare.emplace("2");
|
||||
|
||||
// Do it again.
|
||||
data.emplace("0");
|
||||
compare.emplace("0");
|
||||
|
||||
data.emplace("1");
|
||||
compare.emplace("1");
|
||||
|
||||
data.emplace("2");
|
||||
compare.emplace("2");
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
|
||||
bool isEqual = std::equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value2)
|
||||
{
|
||||
Compare2 compare;
|
||||
Data2 data;
|
||||
|
||||
data.emplace("0", "1");
|
||||
compare.emplace("0", "1");
|
||||
|
||||
data.emplace("1", "2");
|
||||
compare.emplace("1", "2");
|
||||
|
||||
data.emplace("2", "3");
|
||||
compare.emplace("2", "3");
|
||||
|
||||
// Do it again.
|
||||
data.emplace("0", "1");
|
||||
compare.emplace("0", "1");
|
||||
|
||||
data.emplace("1", "2");
|
||||
compare.emplace("1", "2");
|
||||
|
||||
data.emplace("2", "3");
|
||||
compare.emplace("2", "3");
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
|
||||
bool isEqual = std::equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value3)
|
||||
{
|
||||
Compare3 compare;
|
||||
Data3 data;
|
||||
|
||||
data.emplace("0", "1", "2");
|
||||
compare.emplace("0", "1", "2");
|
||||
|
||||
data.emplace("1", "2", "3");
|
||||
compare.emplace("1", "2", "3");
|
||||
|
||||
data.emplace("2", "3", "4");
|
||||
compare.emplace("2", "3", "4");
|
||||
|
||||
// Do it again.
|
||||
data.emplace("0", "1", "2");
|
||||
compare.emplace("0", "1", "2");
|
||||
|
||||
data.emplace("1", "2", "3");
|
||||
compare.emplace("1", "2", "3");
|
||||
|
||||
data.emplace("2", "3", "4");
|
||||
compare.emplace("2", "3", "4");
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
|
||||
bool isEqual = std::equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value4)
|
||||
{
|
||||
Compare4 compare;
|
||||
Data4 data;
|
||||
|
||||
data.emplace("0", "1", "2", "3");
|
||||
compare.emplace("0", "1", "2", "3");
|
||||
|
||||
data.emplace("1", "2", "3", "4");
|
||||
compare.emplace("1", "2", "3", "4");
|
||||
|
||||
data.emplace("2", "3", "4", "5");
|
||||
compare.emplace("2", "3", "4", "5");
|
||||
|
||||
// Do it again.
|
||||
data.emplace("0", "1", "2", "3");
|
||||
compare.emplace("0", "1", "2", "3");
|
||||
|
||||
data.emplace("1", "2", "3", "4");
|
||||
compare.emplace("1", "2", "3", "4");
|
||||
|
||||
data.emplace("2", "3", "4", "5");
|
||||
compare.emplace("2", "3", "4", "5");
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
|
||||
bool isEqual = std::equal(data.begin(),
|
||||
data.end(),
|
||||
compare.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_erase_key)
|
||||
{
|
||||
|
||||
@ -104,6 +104,128 @@ namespace
|
||||
|
||||
std::vector<int> int_data;
|
||||
|
||||
struct D1
|
||||
{
|
||||
D1(const std::string& a_)
|
||||
: a(a_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
};
|
||||
|
||||
struct D2
|
||||
{
|
||||
D2(const std::string& a_, const std::string& b_)
|
||||
: a(a_),
|
||||
b(b_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
};
|
||||
|
||||
struct D3
|
||||
{
|
||||
D3(const std::string& a_, const std::string& b_, const std::string& c_)
|
||||
: a(a_),
|
||||
b(b_),
|
||||
c(c_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
std::string c;
|
||||
};
|
||||
|
||||
struct D4
|
||||
{
|
||||
D4(const std::string& a_, const std::string& b_, const std::string& c_, const std::string& d_)
|
||||
: a(a_),
|
||||
b(b_),
|
||||
c(c_),
|
||||
d(d_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string a;
|
||||
std::string b;
|
||||
std::string c;
|
||||
std::string d;
|
||||
};
|
||||
|
||||
bool operator == (const D1& lhs, const D1& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a);
|
||||
}
|
||||
|
||||
bool operator == (const D2& lhs, const D2& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b);
|
||||
}
|
||||
|
||||
bool operator == (const D3& lhs, const D3& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c);
|
||||
}
|
||||
|
||||
bool operator == (const D4& lhs, const D4& rhs)
|
||||
{
|
||||
return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d);
|
||||
}
|
||||
|
||||
bool operator != (const D1& lhs, const D1& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator != (const D2& lhs, const D2& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator != (const D3& lhs, const D3& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator != (const D4& lhs, const D4& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator < (const D1& lhs, const D1& rhs)
|
||||
{
|
||||
return (lhs.a < rhs.a);
|
||||
}
|
||||
|
||||
bool operator < (const D2& lhs, const D2& rhs)
|
||||
{
|
||||
return (lhs.a < rhs.a) && (lhs.b < rhs.b);
|
||||
}
|
||||
|
||||
bool operator < (const D3& lhs, const D3& rhs)
|
||||
{
|
||||
return (lhs.a < rhs.a) && (lhs.b < rhs.b) && (lhs.c < rhs.c);
|
||||
}
|
||||
|
||||
bool operator < (const D4& lhs, const D4& rhs)
|
||||
{
|
||||
return (lhs.a < rhs.a) && (lhs.b < rhs.b) && (lhs.c < rhs.c) && (lhs.d < rhs.d);
|
||||
}
|
||||
|
||||
typedef etl::flat_set<D1, SIZE> Data1;
|
||||
typedef etl::flat_set<D2, SIZE> Data2;
|
||||
typedef etl::flat_set<D3, SIZE> Data3;
|
||||
typedef etl::flat_set<D4, SIZE> Data4;
|
||||
|
||||
typedef std::set<D1> Compare1;
|
||||
typedef std::set<D2> Compare2;
|
||||
typedef std::set<D3> Compare3;
|
||||
typedef std::set<D4> Compare4;
|
||||
|
||||
//*************************************************************************
|
||||
struct SetupFixture
|
||||
{
|
||||
@ -382,6 +504,118 @@ namespace
|
||||
CHECK(std::is_sorted(data.begin(), data.end()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value1)
|
||||
{
|
||||
Compare1 compare;
|
||||
Data1 data;
|
||||
|
||||
data.emplace("0");
|
||||
compare.emplace("0");
|
||||
|
||||
data.emplace("1");
|
||||
compare.emplace("1");
|
||||
|
||||
data.emplace("2");
|
||||
compare.emplace("2");
|
||||
|
||||
// Do it again.
|
||||
data.emplace("0");
|
||||
compare.emplace("0");
|
||||
|
||||
data.emplace("1");
|
||||
compare.emplace("1");
|
||||
|
||||
data.emplace("2");
|
||||
compare.emplace("2");
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value2)
|
||||
{
|
||||
Compare2 compare;
|
||||
Data2 data;
|
||||
|
||||
data.emplace("0", "1");
|
||||
compare.emplace("0", "1");
|
||||
|
||||
data.emplace("1", "2");
|
||||
compare.emplace("1", "2");
|
||||
|
||||
data.emplace("2", "3");
|
||||
compare.emplace("2", "3");
|
||||
|
||||
// Do it again.
|
||||
data.emplace("0", "1");
|
||||
compare.emplace("0", "1");
|
||||
|
||||
data.emplace("1", "2");
|
||||
compare.emplace("1", "2");
|
||||
|
||||
data.emplace("2", "3");
|
||||
compare.emplace("2", "3");
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value3)
|
||||
{
|
||||
Compare3 compare;
|
||||
Data3 data;
|
||||
|
||||
data.emplace("0", "1", "2");
|
||||
compare.emplace("0", "1", "2");
|
||||
|
||||
data.emplace("1", "2", "3");
|
||||
compare.emplace("1", "2", "3");
|
||||
|
||||
data.emplace("2", "3", "4");
|
||||
compare.emplace("2", "3", "4");
|
||||
|
||||
// Do it again.
|
||||
data.emplace("0", "1", "2");
|
||||
compare.emplace("0", "1", "2");
|
||||
|
||||
data.emplace("1", "2", "3");
|
||||
compare.emplace("1", "2", "3");
|
||||
|
||||
data.emplace("2", "3", "4");
|
||||
compare.emplace("2", "3", "4");
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value4)
|
||||
{
|
||||
Compare4 compare;
|
||||
Data4 data;
|
||||
|
||||
data.emplace("0", "1", "2", "3");
|
||||
compare.emplace("0", "1", "2", "3");
|
||||
|
||||
data.emplace("1", "2", "3", "4");
|
||||
compare.emplace("1", "2", "3", "4");
|
||||
|
||||
data.emplace("2", "3", "4", "5");
|
||||
compare.emplace("2", "3", "4", "5");
|
||||
|
||||
// Do it again.
|
||||
data.emplace("0", "1", "2", "3");
|
||||
compare.emplace("0", "1", "2", "3");
|
||||
|
||||
data.emplace("1", "2", "3", "4");
|
||||
compare.emplace("1", "2", "3", "4");
|
||||
|
||||
data.emplace("2", "3", "4", "5");
|
||||
compare.emplace("2", "3", "4", "5");
|
||||
|
||||
CHECK_EQUAL(compare.size(), data.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_erase_key)
|
||||
{
|
||||
|
||||
@ -461,6 +461,49 @@ namespace
|
||||
CHECK_THROW(data.insert(excess_data.begin(), excess_data.end()), etl::set_full);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_emplace_value)
|
||||
{
|
||||
//Compare_Data compare_data;
|
||||
//Data data;
|
||||
|
||||
//std::pair<Data::iterator, bool> data_result = data.emplace(0);
|
||||
//std::pair<Compare_Data::iterator, bool> compare_result = compare_data.emplace(0);
|
||||
|
||||
//// Check that both return successful return results
|
||||
//CHECK_EQUAL(*data_result.first, *compare_result.first);
|
||||
|
||||
//// Try adding a duplicate (should return iterator pointing to duplicate)
|
||||
//data_result = data.insert(0);
|
||||
//compare_result = compare_data.insert(0);
|
||||
|
||||
//// Check that both return successful return results
|
||||
//CHECK_EQUAL(*data_result.first, *compare_result.first);
|
||||
|
||||
//// Check that elements in set are the same
|
||||
//bool isEqual = Check_Equal(data.begin(),
|
||||
// data.end(),
|
||||
// compare_data.begin());
|
||||
//CHECK(isEqual);
|
||||
|
||||
//data.insert(2);
|
||||
//compare_data.insert(2);
|
||||
|
||||
//isEqual = Check_Equal(data.begin(),
|
||||
// data.end(),
|
||||
// compare_data.begin());
|
||||
|
||||
//CHECK(isEqual);
|
||||
|
||||
//data.insert(1);
|
||||
//compare_data.insert(1);
|
||||
|
||||
//isEqual = Check_Equal(data.begin(),
|
||||
// data.end(),
|
||||
// compare_data.begin());
|
||||
|
||||
//CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal_range)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user