1 // { dg-do compile { target c++11 } }
2 #include <unordered_map>
4 static_assert( std::is_default_constructible
<std::unordered_map
<int, int>>{}, "" );
7 struct NoDefaultConsAlloc
11 NoDefaultConsAlloc(int) noexcept
{ }
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>>>;
44 Map4::allocator_type
a(1);
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
};
50 Map4 m6
{std::move(m
)};
51 Map4 m7
{std::move(m6
), a
};