mirror of
https://github.com/boostorg/container.git
synced 2025-08-01 21:44:27 +02:00
Merge branch 'JanEisenhauer-patch-1' into develop
This commit is contained in:
@@ -1465,7 +1465,7 @@ class flat_map
|
||||
//! <b>Complexity</b>: Logarithmic.
|
||||
template<class K>
|
||||
BOOST_CONTAINER_FORCEINLINE std::pair<iterator,iterator> equal_range(const K& x)
|
||||
{ return dtl::force_copy<std::pair<iterator,iterator> >(m_flat_tree.lower_bound_range(x)); }
|
||||
{ return dtl::force_copy<std::pair<iterator,iterator> >(m_flat_tree.equal_range(x)); }
|
||||
|
||||
//! <b>Requires</b>: This overload is available only if
|
||||
//! key_compare::is_transparent exists.
|
||||
@@ -1475,7 +1475,7 @@ 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
|
||||
{ return dtl::force_copy<std::pair<const_iterator,const_iterator> >(m_flat_tree.lower_bound_range(x)); }
|
||||
{ return dtl::force_copy<std::pair<const_iterator,const_iterator> >(m_flat_tree.equal_range(x)); }
|
||||
|
||||
//! <b>Effects</b>: Extracts the internal sequence container.
|
||||
//!
|
||||
|
@@ -1031,7 +1031,7 @@ class flat_set
|
||||
//! <b>Complexity</b>: Logarithmic
|
||||
template<typename K>
|
||||
std::pair<iterator,iterator> equal_range(const K& x)
|
||||
{ return this->tree_t::lower_bound_range(x); }
|
||||
{ return this->tree_t::equal_range(x); }
|
||||
|
||||
//! <b>Requires</b>: This overload is available only if
|
||||
//! key_compare::is_transparent exists.
|
||||
@@ -1041,7 +1041,7 @@ class flat_set
|
||||
//! <b>Complexity</b>: Logarithmic
|
||||
template<typename K>
|
||||
std::pair<const_iterator,const_iterator> equal_range(const K& x) const
|
||||
{ return this->tree_t::lower_bound_range(x); }
|
||||
{ return this->tree_t::equal_range(x); }
|
||||
|
||||
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "../../intrusive/test/iterator_test.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
|
||||
using namespace boost::container;
|
||||
@@ -560,6 +561,37 @@ bool test_heterogeneous_lookups()
|
||||
return true;
|
||||
}
|
||||
|
||||
// An ordered sequence of std:pair is also ordered by std::pair::first.
|
||||
struct with_lookup_by_first
|
||||
{
|
||||
typedef void is_transparent;
|
||||
inline bool operator()(std::pair<int, int> a, std::pair<int, int> b) const
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
inline bool operator()(std::pair<int, int> a, int first) const
|
||||
{
|
||||
return a.first < first;
|
||||
}
|
||||
inline bool operator()(int first, std::pair<int, int> b) const
|
||||
{
|
||||
return first < b.first;
|
||||
}
|
||||
};
|
||||
|
||||
bool test_heterogeneous_lookup_by_partial_key()
|
||||
{
|
||||
typedef flat_map<std::pair<int, int>,int, with_lookup_by_first> map_t;
|
||||
|
||||
map_t map1;
|
||||
map1[std::pair<int, int>(0, 1)] = 3;
|
||||
map1[std::pair<int, int>(0, 2)] = 3;
|
||||
|
||||
std::pair<map_t::iterator, map_t::iterator> const first_0_range = map1.equal_range(0);
|
||||
|
||||
return 2 == first_0_range.second - first_0_range.first;
|
||||
}
|
||||
|
||||
}}} //namespace boost::container::test
|
||||
|
||||
int main()
|
||||
@@ -620,6 +652,9 @@ int main()
|
||||
if (!test_heterogeneous_lookups())
|
||||
return 1;
|
||||
|
||||
if (!test_heterogeneous_lookup_by_partial_key())
|
||||
return 1;
|
||||
|
||||
////////////////////////////////////
|
||||
// Testing allocator implementations
|
||||
////////////////////////////////////
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/container/flat_set.hpp>
|
||||
@@ -576,6 +577,37 @@ bool test_heterogeneous_lookups()
|
||||
return true;
|
||||
}
|
||||
|
||||
// An ordered sequence of std:pair is also ordered by std::pair::first.
|
||||
struct with_lookup_by_first
|
||||
{
|
||||
typedef void is_transparent;
|
||||
inline bool operator()(std::pair<int, int> a, std::pair<int, int> b) const
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
inline bool operator()(std::pair<int, int> a, int first) const
|
||||
{
|
||||
return a.first < first;
|
||||
}
|
||||
inline bool operator()(int first, std::pair<int, int> b) const
|
||||
{
|
||||
return first < b.first;
|
||||
}
|
||||
};
|
||||
|
||||
bool test_heterogeneous_lookup_by_partial_key()
|
||||
{
|
||||
typedef flat_set<std::pair<int, int>, with_lookup_by_first> set_t;
|
||||
|
||||
set_t set1;
|
||||
set1.insert(std::pair<int, int>(0, 1));
|
||||
set1.insert(std::pair<int, int>(0, 2));
|
||||
|
||||
std::pair<set_t::iterator, set_t::iterator> const first_0_range = set1.equal_range(0);
|
||||
|
||||
return 2 == first_0_range.second - first_0_range.first;
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
template<class VoidAllocatorOrContainer>
|
||||
@@ -717,6 +749,10 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!test_heterogeneous_lookup_by_partial_key()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// Testing allocator implementations
|
||||
////////////////////////////////////
|
||||
|
Reference in New Issue
Block a user