forked from boostorg/container
Fix "count" with heterogeneous lookups in flat_map and flat_set
This commit is contained in:
@@ -1343,9 +1343,7 @@ class flat_map
|
|||||||
//!
|
//!
|
||||||
//! <b>Complexity</b>: log(size())+count(k)
|
//! <b>Complexity</b>: log(size())+count(k)
|
||||||
BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) const
|
BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& x) const
|
||||||
//Don't use find() != end optimization here as transparent comparators with key K might
|
{ return static_cast<size_type>(m_flat_tree.find(x) != m_flat_tree.end()); }
|
||||||
//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
|
//! <b>Requires</b>: This overload is available only if
|
||||||
//! key_compare::is_transparent exists.
|
//! key_compare::is_transparent exists.
|
||||||
@@ -1355,7 +1353,9 @@ class flat_map
|
|||||||
//! <b>Complexity</b>: log(size())+count(k)
|
//! <b>Complexity</b>: log(size())+count(k)
|
||||||
template<class K>
|
template<class K>
|
||||||
BOOST_CONTAINER_FORCEINLINE size_type count(const K& x) const
|
BOOST_CONTAINER_FORCEINLINE size_type count(const K& 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>Returns</b>: Returns true if there is an element with key
|
//! <b>Returns</b>: Returns true if there is an element with key
|
||||||
//! equivalent to key in the container, otherwise false.
|
//! equivalent to key in the container, otherwise false.
|
||||||
|
Reference in New Issue
Block a user