OSDN Git Service

PR libstdc++/49060
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / backward / hash_set / 49060.cc
1 // { dg-options "-Wno-deprecated" }
2
3 #include <backward/hashtable.h>
4 #include <utility>
5
6 struct modulo2_hash
7 {
8   size_t operator()(int const key) const
9   {
10     return key % 2;
11   }
12 };
13
14 struct modulo2_eq
15 {
16   bool operator()(int const left, int const right) const
17   {
18     return left % 2 == right % 2;
19   }
20 };
21
22 int main()
23 {
24   typedef std::_Select1st<std::pair<int const, int> > extract_type;
25   typedef
26     __gnu_cxx::hashtable<std::pair<int const, int>, int, modulo2_hash,
27                          extract_type, modulo2_eq, std::allocator<int> >
28       table_type;
29   table_type table(4, modulo2_hash(), modulo2_eq(), extract_type(),
30                    std::allocator<int>());
31
32   table.insert_equal(std::make_pair(2, 1));
33   table_type::iterator it(table.insert_equal(std::make_pair(4, 2)));
34   table.erase(it->first);
35 }