Fixes #241: flat_map should support same interface as std::map

This commit is contained in:
Ion Gaztañaga
2024-06-28 14:04:00 +02:00
parent 6f10e52887
commit df03ffc8ec
8 changed files with 142 additions and 3 deletions
+34
View File
@@ -1315,6 +1315,23 @@ class flat_map
inline size_type erase(const key_type& x)
{ return m_flat_tree.erase_unique(x); }
//! <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 (0/1).
template <class K>
inline BOOST_CONTAINER_DOC1ST
(size_type
, typename dtl::enable_if_c<
dtl::is_transparent<key_compare>::value && //transparent
!dtl::is_convertible<K BOOST_MOVE_I iterator>::value && //not convertible to iterator
!dtl::is_convertible<K BOOST_MOVE_I const_iterator>::value //not convertible to const_iterator
BOOST_MOVE_I size_type>::type)
erase(const K& x)
{ return m_flat_tree.erase_unique(x); }
//! <b>Effects</b>: Erases all the elements in the range [first, last).
//!
//! <b>Returns</b>: Returns last.
@@ -2678,6 +2695,23 @@ class flat_multimap
inline size_type erase(const key_type& x)
{ return m_flat_tree.erase(x); }
//! <b>Requires</b>: This overload is available only if
//! key_compare::is_transparent exists.
//!
//! <b>Effects</b>: Erases all elements in the container with key equivalent to x.
//!
//! <b>Returns</b>: Returns the number of erased elements.
template <class K>
inline BOOST_CONTAINER_DOC1ST
(size_type
, typename dtl::enable_if_c<
dtl::is_transparent<key_compare>::value && //transparent
!dtl::is_convertible<K BOOST_MOVE_I iterator>::value && //not convertible to iterator
!dtl::is_convertible<K BOOST_MOVE_I const_iterator>::value //not convertible to const_iterator
BOOST_MOVE_I size_type>::type)
erase(const K& x)
{ return m_flat_tree.erase(x); }
//! <b>Effects</b>: Erases all the elements in the range [first, last).
//!
//! <b>Returns</b>: Returns last.