| 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 | // UNSUPPORTED: c++03, c++11, c++14 |
| 10 | |
| 11 | // <unordered_set> |
| 12 | |
| 13 | // template<class InputIterator, |
| 14 | // class Hash = hash<iter-value-type<InputIterator>>, |
| 15 | // class Pred = equal_to<iter-value-type<InputIterator>>, |
| 16 | // class Allocator = allocator<iter-value-type<InputIterator>>> |
| 17 | // unordered_set(InputIterator, InputIterator, typename see below::size_type = see below, |
| 18 | // Hash = Hash(), Pred = Pred(), Allocator = Allocator()) |
| 19 | // -> unordered_set<iter-value-type<InputIterator>, |
| 20 | // Hash, Pred, Allocator>; |
| 21 | // |
| 22 | // template<class T, class Hash = hash<T>, |
| 23 | // class Pred = equal_to<T>, class Allocator = allocator<T>> |
| 24 | // unordered_set(initializer_list<T>, typename see below::size_type = see below, |
| 25 | // Hash = Hash(), Pred = Pred(), Allocator = Allocator()) |
| 26 | // -> unordered_set<T, Hash, Pred, Allocator>; |
| 27 | // |
| 28 | // template<class InputIterator, class Allocator> |
| 29 | // unordered_set(InputIterator, InputIterator, typename see below::size_type, Allocator) |
| 30 | // -> unordered_set<iter-value-type<InputIterator>, |
| 31 | // hash<iter-value-type<InputIterator>>, |
| 32 | // equal_to<iter-value-type<InputIterator>>, |
| 33 | // Allocator>; |
| 34 | // |
| 35 | // template<class InputIterator, class Hash, class Allocator> |
| 36 | // unordered_set(InputIterator, InputIterator, typename see below::size_type, |
| 37 | // Hash, Allocator) |
| 38 | // -> unordered_set<iter-value-type<InputIterator>, Hash, |
| 39 | // equal_to<iter-value-type<InputIterator>>, |
| 40 | // Allocator>; |
| 41 | // |
| 42 | // template<class T, class Allocator> |
| 43 | // unordered_set(initializer_list<T>, typename see below::size_type, Allocator) |
| 44 | // -> unordered_set<T, hash<T>, equal_to<T>, Allocator>; |
| 45 | // |
| 46 | // template<class T, class Hash, class Allocator> |
| 47 | // unordered_set(initializer_list<T>, typename see below::size_type, Hash, Allocator) |
| 48 | // -> unordered_set<T, Hash, equal_to<T>, Allocator>; |
| 49 | |
| 50 | #include <functional> |
| 51 | #include <unordered_set> |
| 52 | |
| 53 | int main(int, char**) { |
| 54 | { |
| 55 | // cannot deduce Key from nothing |
| 56 | std::unordered_set s; |
| 57 | // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_set'}} |
| 58 | } |
| 59 | { |
| 60 | // cannot deduce Key from just (Size) |
| 61 | std::unordered_set s(42); |
| 62 | // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_set'}} |
| 63 | } |
| 64 | { |
| 65 | // cannot deduce Key from just (Size, Hash) |
| 66 | std::unordered_set s(42, std::hash<int>()); |
| 67 | // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_set'}} |
| 68 | } |
| 69 | { |
| 70 | // cannot deduce Key from just (Size, Hash, Pred) |
| 71 | std::unordered_set s(42, std::hash<int>(), std::equal_to<>()); |
| 72 | // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_set'}} |
| 73 | } |
| 74 | { |
| 75 | // cannot deduce Key from just (Size, Hash, Pred, Allocator) |
| 76 | std::unordered_set s(42, std::hash<int>(), std::equal_to<>(), std::allocator<int>()); |
| 77 | // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_set'}} |
| 78 | } |
| 79 | { |
| 80 | // cannot deduce Key from just (Allocator) |
| 81 | std::unordered_set s(std::allocator<int>{}); |
| 82 | // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_set'}} |
| 83 | } |
| 84 | { |
| 85 | // cannot deduce Key from just (Size, Allocator) |
| 86 | std::unordered_set s(42, std::allocator<int>()); |
| 87 | // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_set'}} |
| 88 | } |
| 89 | { |
| 90 | // cannot deduce Key from just (Size, Hash, Allocator) |
| 91 | std::unordered_set s(42, std::hash<short>(), std::allocator<int>()); |
| 92 | // expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_set'}} |
| 93 | } |
| 94 | |
| 95 | return 0; |
| 96 | } |
| 97 | |