forked from boostorg/container
Fix "count" with heterogeneous lookups in flat_map and flat_set
This commit is contained in:
@@ -1343,7 +1343,9 @@ class flat_map
|
||||
//!
|
||||
//! <b>Complexity</b>: log(size())+count(k)
|
||||
BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) const
|
||||
{ return static_cast<size_type>(m_flat_tree.find(x) != m_flat_tree.end()); }
|
||||
//Don't use find() != end optimization here as transparent comparators with key K might
|
||||
//return a different range than key_type (which can only return a single element range)
|
||||
{ return m_flat_tree.count(x); }
|
||||
|
||||
//! <b>Requires</b>: This overload is available only if
|
||||
//! key_compare::is_transparent exists.
|
||||
@@ -1465,6 +1467,8 @@ class flat_map
|
||||
//! <b>Complexity</b>: Logarithmic.
|
||||
template<class K>
|
||||
BOOST_CONTAINER_FORCEINLINE std::pair<iterator,iterator> equal_range(const K& x)
|
||||
//Don't use lower_bound_range optimization here as transparent comparators with key K might
|
||||
//return a different range than key_type (which can only return a single element range)
|
||||
{ return dtl::force_copy<std::pair<iterator,iterator> >(m_flat_tree.equal_range(x)); }
|
||||
|
||||
//! <b>Requires</b>: This overload is available only if
|
||||
@@ -1475,6 +1479,8 @@ class flat_map
|
||||
//! <b>Complexity</b>: Logarithmic.
|
||||
template<class K>
|
||||
BOOST_CONTAINER_FORCEINLINE std::pair<const_iterator, const_iterator> equal_range(const K& x) const
|
||||
//Don't use lower_bound_range optimization here as transparent comparators with key K might
|
||||
//return a different range than key_type (which can only return a single element range)
|
||||
{ return dtl::force_copy<std::pair<const_iterator,const_iterator> >(m_flat_tree.equal_range(x)); }
|
||||
|
||||
//! <b>Effects</b>: Extracts the internal sequence container.
|
||||
|
||||
Reference in New Issue
Block a user