PR modula2/115112 Incorrect line debugging information occurs during INC builtin
[gcc.git] / libstdc++-v3 / testsuite / 23_containers / unordered_map / cons / default.cc
blob7a785e980b1fc88f70ec988cef3efec1ea1ef11d
1 // { dg-do compile { target c++11 } }
2 #include <unordered_map>
4 static_assert( std::is_default_constructible<std::unordered_map<int, int>>{}, "" );
6 template<typename T>
7 struct NoDefaultConsAlloc
9 using value_type = T;
11 NoDefaultConsAlloc(int) noexcept { }
13 template<typename U>
14 NoDefaultConsAlloc(const NoDefaultConsAlloc<U>&) { }
16 T *allocate(std::size_t n)
17 { return std::allocator<T>().allocate(n); }
19 void deallocate(T *p, std::size_t n)
20 { std::allocator<T>().deallocate(p, n); }
22 bool operator==(const NoDefaultConsAlloc&) const { return true; }
23 bool operator!=(const NoDefaultConsAlloc&) const { return false; }
26 using Map = std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
27 NoDefaultConsAlloc<std::pair<const int, int>>>;
28 static_assert( ! std::is_default_constructible<Map>{}, "PR libstdc++/100863" );
30 struct Hash : std::hash<int> { Hash(int) { } };
31 using Map2 = std::unordered_map<int, int, Hash>;
32 static_assert( ! std::is_default_constructible<Map2>{}, "PR libstdc++/100863" );
34 struct Equal : std::equal_to<int> { Equal(int) { } };
35 using Map3 = std::unordered_map<int, int, std::hash<int>, Equal>;
36 static_assert( ! std::is_default_constructible<Map3>{}, "PR libstdc++/100863" );
38 // PR libstdc++/101583
39 // verify non-default ctors can still be used
40 using Map4 = std::unordered_map<int, int, Hash, Equal,
41 NoDefaultConsAlloc<std::pair<const int, int>>>;
42 Hash h(1);
43 Equal eq(1);
44 Map4::allocator_type a(1);
45 Map4 m{1, h, eq, a};
46 Map4 m2{m.begin(), m.end(), m.size(), h, eq, a};
47 Map4 m3{{{1,1}, {2,2}, {3,3}}, 3, h, eq, a};
48 Map4 m4{m};
49 Map4 m5{m, a};
50 Map4 m6{std::move(m)};
51 Map4 m7{std::move(m6), a};