Add small test to set/flat_map for transparent erase

This commit is contained in:
Ion Gaztañaga
2025-11-05 15:04:50 +01:00
parent 5610e49409
commit d179658a08
3 changed files with 33 additions and 0 deletions

View File

@@ -801,6 +801,15 @@ class flat_set
//! linear to the elements with bigger keys.
iterator erase(const_iterator first, const_iterator last);
//! <b>Requires</b>: This overload is available only if
//! key_compare::is_transparent exists.
//!
//! <b>Effects</b>: If present, erases the element in the container with key equivalent to x.
//!
//! <b>Returns</b>: Returns the number of erased elements.
template<class K>
size_type erase(K && k);
//! <b>Effects</b>: Swaps the contents of *this and x.
//!
//! <b>Throws</b>: Nothing.
@@ -1736,6 +1745,10 @@ class flat_multiset
//! @copydoc ::boost::container::flat_set::erase(const_iterator,const_iterator)
iterator erase(const_iterator first, const_iterator last);
//! @copydoc ::boost::container::flat_set::erase(K&&)
template<class K>
size_type erase(K && k);
//! @copydoc ::boost::container::flat_set::swap
void swap(flat_multiset& x)
BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value

View File

@@ -580,6 +580,16 @@ bool test_heterogeneous_lookups()
if(*cmset1.equal_range(find_me).second != 3)
return false;
//erase
if (set1.erase(find_me) != 1)
return false;
if (set1.erase(find_me) != 0)
return false;
if (mset1.erase(find_me) != 2)
return false;
if (mset1.erase(find_me) != 0)
return false;
return true;
}

View File

@@ -437,6 +437,16 @@ bool test_heterogeneous_lookups()
if(*cmset1.equal_range(find_me).second != 3)
return false;
//erase
if (set1.erase(find_me) != 1)
return false;
if (set1.erase(find_me) != 0)
return false;
if (mset1.erase(find_me) != 2)
return false;
if (mset1.erase(find_me) != 0)
return false;
return true;
}