Implement full support for non-pointer types in custom allocators. This is for the associative containers only. This work still needs to be done on the unordered and sequence containers. Fixes http://llvm.org/bugs/show_bug.cgi?id=15978
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@184358 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -17,9 +17,12 @@
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pair<const int, double> V;
|
||||
{
|
||||
typedef std::multimap<int, double> M;
|
||||
{
|
||||
typedef std::pair<M::iterator, M::iterator> R;
|
||||
@@ -95,4 +98,84 @@ int main()
|
||||
assert(r.first == m.end());
|
||||
assert(r.second == m.end());
|
||||
}
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
|
||||
{
|
||||
typedef std::pair<M::iterator, M::iterator> R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 1),
|
||||
V(5, 2),
|
||||
V(5, 3),
|
||||
V(7, 1),
|
||||
V(7, 2),
|
||||
V(7, 3),
|
||||
V(9, 1),
|
||||
V(9, 2),
|
||||
V(9, 3)
|
||||
};
|
||||
M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.equal_range(4);
|
||||
assert(r.first == m.begin());
|
||||
assert(r.second == m.begin());
|
||||
r = m.equal_range(5);
|
||||
assert(r.first == m.begin());
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(6);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(7);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(8);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(9);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 9));
|
||||
r = m.equal_range(10);
|
||||
assert(r.first == m.end());
|
||||
assert(r.second == m.end());
|
||||
}
|
||||
{
|
||||
typedef std::pair<M::const_iterator, M::const_iterator> R;
|
||||
V ar[] =
|
||||
{
|
||||
V(5, 1),
|
||||
V(5, 2),
|
||||
V(5, 3),
|
||||
V(7, 1),
|
||||
V(7, 2),
|
||||
V(7, 3),
|
||||
V(9, 1),
|
||||
V(9, 2),
|
||||
V(9, 3)
|
||||
};
|
||||
const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
|
||||
R r = m.equal_range(4);
|
||||
assert(r.first == m.begin());
|
||||
assert(r.second == m.begin());
|
||||
r = m.equal_range(5);
|
||||
assert(r.first == m.begin());
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(6);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 3));
|
||||
r = m.equal_range(7);
|
||||
assert(r.first == next(m.begin(), 3));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(8);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 6));
|
||||
r = m.equal_range(9);
|
||||
assert(r.first == next(m.begin(), 6));
|
||||
assert(r.second == next(m.begin(), 9));
|
||||
r = m.equal_range(10);
|
||||
assert(r.first == m.end());
|
||||
assert(r.second == m.end());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user