Debian Codegraph @

libstdc++-v3/testsuite/23_containers/unordered_map/insert/115285.cc

raw
1 // { dg-do run { target c++11 } }
2
3 // PR libstdc++/115285
4
5 #include <unordered_map>
6 #include <iterator>
7 #include <testsuite_hooks.h>
8
9 struct Pair
10 {
11 explicit operator std::pair<const int, int>() const&& { return {1, 2}; }
12 };
13
14 void
15 test01()
16 {
17 Pair p[2];
18 auto mi = std::make_move_iterator(p);
19 auto me = std::make_move_iterator(p+2);
20 std::unordered_map<int, int> m(mi, me);
21 VERIFY( m.size() == 1 );
22 }
23
24 struct K {
25 explicit K(int) noexcept { }
26 bool operator==(const K&) const { return true; }
27 };
28
29 template<> struct std::hash<K> {
30 std::size_t operator()(const K&) const { return 0ul; }
31 };
32
33 void
34 test02()
35 {
36 const std::pair<int, int> p[2]{{1,2}, {3,4}};
37 auto mi = std::make_move_iterator(p);
38 auto me = std::make_move_iterator(p+2);
39 std::unordered_map<K, int> m(mi, me);
40 VERIFY( m.size() == 1 );
41 }
42
43 int main()
44 {
45 test01();
46 test02();
47 }