1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <unordered_set>
10 // UNSUPPORTED: c++03, c++11, c++14
11 // UNSUPPORTED: libcpp-no-deduction-guides
12 // XFAIL: clang-6, apple-clang-9.0, apple-clang-9.1, apple-clang-10.0.0
13 
14 // template<class InputIterator,
15 //        class Hash = hash<iter-value-type<InputIterator>>,
16 //        class Pred = equal_to<iter-value-type<InputIterator>>,
17 //        class Allocator = allocator<iter-value-type<InputIterator>>>
18 // unordered_set(InputIterator, InputIterator, typename see below::size_type = see below,
19 //               Hash = Hash(), Pred = Pred(), Allocator = Allocator())
20 //   -> unordered_set<iter-value-type<InputIterator>,
21 //                    Hash, Pred, Allocator>;
22 //
23 // template<class T, class Hash = hash<T>,
24 //        class Pred = equal_to<T>, class Allocator = allocator<T>>
25 // unordered_set(initializer_list<T>, typename see below::size_type = see below,
26 //               Hash = Hash(), Pred = Pred(), Allocator = Allocator())
27 //   -> unordered_set<T, Hash, Pred, Allocator>;
28 //
29 // template<class InputIterator, class Allocator>
30 // unordered_set(InputIterator, InputIterator, typename see below::size_type, Allocator)
31 //   -> unordered_set<iter-value-type<InputIterator>,
32 //                    hash<iter-value-type<InputIterator>>,
33 //                    equal_to<iter-value-type<InputIterator>>,
34 //                    Allocator>;
35 //
36 // template<class InputIterator, class Hash, class Allocator>
37 // unordered_set(InputIterator, InputIterator, typename see below::size_type,
38 //               Hash, Allocator)
39 //   -> unordered_set<iter-value-type<InputIterator>, Hash,
40 //                    equal_to<iter-value-type<InputIterator>>,
41 //                    Allocator>;
42 //
43 // template<class T, class Allocator>
44 // unordered_set(initializer_list<T>, typename see below::size_type, Allocator)
45 //   -> unordered_set<T, hash<T>, equal_to<T>, Allocator>;
46 //
47 // template<class T, class Hash, class Allocator>
48 // unordered_set(initializer_list<T>, typename see below::size_type, Hash, Allocator)
49 //   -> unordered_set<T, Hash, equal_to<T>, Allocator>;
50 
51 #include <functional>
52 #include <unordered_set>
53 
main(int,char **)54 int main(int, char**)
55 {
56     {
57         // cannot deduce Key from nothing
58         std::unordered_set s;
59             // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'unordered_set'}}
60     }
61     {
62         // cannot deduce Key from just (Size)
63         std::unordered_set s(42);
64             // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'unordered_set'}}
65     }
66     {
67         // cannot deduce Key from just (Size, Hash)
68         std::unordered_set s(42, std::hash<int>());
69             // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'unordered_set'}}
70     }
71     {
72         // cannot deduce Key from just (Size, Hash, Pred)
73         std::unordered_set s(42, std::hash<int>(), std::equal_to<>());
74             // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'unordered_set'}}
75     }
76     {
77         // cannot deduce Key from just (Size, Hash, Pred, Allocator)
78         std::unordered_set s(42, std::hash<int>(), std::equal_to<>(), std::allocator<int>());
79             // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'unordered_set'}}
80     }
81     {
82         // cannot deduce Key from just (Allocator)
83         std::unordered_set s(std::allocator<int>{});
84             // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'unordered_set'}}
85     }
86     {
87         // cannot deduce Key from just (Size, Allocator)
88         std::unordered_set s(42, std::allocator<int>());
89             // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'unordered_set'}}
90     }
91     {
92         // cannot deduce Key from just (Size, Hash, Allocator)
93         std::unordered_set s(42, std::hash<short>(), std::allocator<int>());
94             // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'unordered_set'}}
95     }
96 
97     return 0;
98 }
99