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