1 // { dg-do run { target c++11 } }
3 // Bug 117921 - containers do not use ADL swap for Compare, Pred or Hash types
5 #include <unordered_set>
6 #include <testsuite_hooks.h>
10 struct Hash
: std::hash
<int>
13 friend void swap(Hash
&, Hash
&) { swapped
= true; }
15 bool Hash::swapped
= false;
17 struct Eq
: std::equal_to
<int>
20 friend void swap(Eq
&, Eq
&) { swapped
= true; }
22 bool Eq::swapped
= false;
28 bool Allocator_base::swapped
= false;
33 struct Allocator
: Allocator_base
38 template<typename U
> Allocator(const Allocator
<U
>&) { }
40 T
* allocate(size_t n
) { return std::allocator
<T
>().allocate(n
); }
41 void deallocate(T
* p
, size_t n
) { std::allocator
<T
>().deallocate(p
, n
); }
43 using propagate_on_container_swap
= std::true_type
;
45 friend void swap(Allocator
&, Allocator
&) { swapped
= true; }
46 friend bool operator==(Allocator
, Allocator
) { return true; }
53 std::unordered_set
<int, adl::Eq
, adl::Hash
, adl::Allocator
<int>> s1
, s2
;
55 VERIFY( adl::Hash::swapped
);
56 VERIFY( adl::Eq::swapped
);
57 VERIFY( adl::Allocator_base::swapped
);