| 1 | // { dg-do run { target c++11 } } |
| 2 | |
| 3 | #include <map> |
| 4 | #include <memory> |
| 5 | #include <testsuite_hooks.h> |
| 6 | #include <testsuite_allocator.h> |
| 7 | |
| 8 | struct T { int i; }; |
| 9 | |
| 10 | bool operator<(const T& l, const T& r) |
| 11 | { return l.i < r.i; } |
| 12 | |
| 13 | struct L : std::less<T> |
| 14 | { }; |
| 15 | |
| 16 | using __gnu_test::CustomPointerAlloc; |
| 17 | |
| 18 | template class std::map<T, int, L, |
| 19 | CustomPointerAlloc<std::pair<const T, int>>>; |
| 20 | |
| 21 | void test01() |
| 22 | { |
| 23 | typedef CustomPointerAlloc<std::pair<const T, int>> alloc_type; |
| 24 | typedef std::map<T, int, L, alloc_type> test_type; |
| 25 | test_type v; |
| 26 | v.insert({ T(), 0 }); |
| 27 | VERIFY( v.begin()->second == 0 ); |
| 28 | VERIFY( ++v.begin() == v.end() ); |
| 29 | v.insert({ T { 1 }, 1 }); |
| 30 | VERIFY( v.size() == 2 ); |
| 31 | VERIFY( v.find(T()) != v.end() ); |
| 32 | } |
| 33 | |
| 34 | int main() |
| 35 | { |
| 36 | test01(); |
| 37 | } |