| 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_map(InputIterator, InputIterator, typename see below::size_type = see below, |
| 18 |
// Hash = Hash(), Pred = Pred(), Allocator = Allocator()) |
| 19 |
// -> unordered_map<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_map(initializer_list<pair<Key, T>>, |
| 25 |
// typename see below::size_type = see below, Hash = Hash(), |
| 26 |
// Pred = Pred(), Allocator = Allocator()) |
| 27 |
// -> unordered_map<Key, T, Hash, Pred, Allocator>; |
| 28 |
// |
| 29 |
// template<class InputIterator, class Allocator> |
| 30 |
// unordered_map(InputIterator, InputIterator, typename see below::size_type, Allocator) |
| 31 |
// -> unordered_map<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_map(InputIterator, InputIterator, Allocator) |
| 37 |
// -> unordered_map<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_map(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator) |
| 43 |
// -> unordered_map<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_map(initializer_list<pair<Key, T>>, typename see below::size_type, Allocator) |
| 48 |
// -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; |
| 49 |
// |
| 50 |
// template<class Key, class T, class Allocator> |
| 51 |
// unordered_map(initializer_list<pair<Key, T>>, Allocator) |
| 52 |
// -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; |
| 53 |
// |
| 54 |
// template<class Key, class T, class Hash, class Allocator> |
| 55 |
// unordered_map(initializer_list<pair<Key, T>>, typename see below::size_type, Hash, |
| 56 |
// Allocator) |
| 57 |
// -> unordered_map<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_map m; // expected-error-re{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_map'}} |
| 68 |
} |
| 69 |
{ |
| 70 |
// cannot deduce Key from just (Size) |
| 71 |
std::unordered_map m(42); // expected-error-re{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_map'}} |
| 72 |
} |
| 73 |
{ |
| 74 |
// cannot deduce Key from just (Size, Hash) |
| 75 |
std::unordered_map m(42, std::hash<int>()); |
| 76 |
// expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_map'}} |
| 77 |
} |
| 78 |
{ |
| 79 |
// cannot deduce Key from just (Size, Hash, Pred) |
| 80 |
std::unordered_map m(42, std::hash<int>(), std::equal_to<int>()); |
| 81 |
// expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_map'}} |
| 82 |
} |
| 83 |
{ |
| 84 |
// cannot deduce Key from just (Size, Hash, Pred, Allocator) |
| 85 |
std::unordered_map m(42, std::hash<int>(), std::equal_to<int>(), std::allocator<P>()); |
| 86 |
// expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_map'}} |
| 87 |
} |
| 88 |
{ |
| 89 |
// cannot deduce Key from just (Allocator) |
| 90 |
std::unordered_map m(std::allocator<P>{}); |
| 91 |
// expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_map'}} |
| 92 |
} |
| 93 |
{ |
| 94 |
// cannot deduce Key from just (Size, Allocator) |
| 95 |
std::unordered_map m(42, std::allocator<P>()); |
| 96 |
// expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_map'}} |
| 97 |
} |
| 98 |
{ |
| 99 |
// cannot deduce Key from just (Size, Hash, Allocator) |
| 100 |
std::unordered_map m(42, std::hash<int>(), std::allocator<P>()); |
| 101 |
// expected-error-re@-1{{no viable constructor or deduction guide for deduction of template arguments of '{{(std::)?}}unordered_map'}} |
| 102 |
} |
| 103 |
|
| 104 |
return 0; |
| 105 |
} |