Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / associative / multimap / multimap.cons / deduct.verify.cpp
blob1fda02638ef652ec607f37d773b853499fa20290
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
11 // <map>
13 // template<class InputIterator,
14 // class Compare = less<iter-value-type<InputIterator>>,
15 // class Allocator = allocator<iter-value-type<InputIterator>>>
16 // multimap(InputIterator, InputIterator,
17 // Compare = Compare(), Allocator = Allocator())
18 // -> multimap<iter-value-type<InputIterator>, Compare, Allocator>;
19 // template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
20 // multimap(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
21 // -> multimap<Key, Compare, Allocator>;
22 // template<class InputIterator, class Allocator>
23 // multimap(InputIterator, InputIterator, Allocator)
24 // -> multimap<iter-value-type<InputIterator>, less<iter-value-type<InputIterator>>, Allocator>;
25 // template<class Key, class Allocator>
26 // multimap(initializer_list<Key>, Allocator)
27 // -> multimap<Key, less<Key>, Allocator>;
29 #include <climits> // INT_MAX
30 #include <functional>
31 #include <map>
32 #include <type_traits>
34 struct NotAnAllocator {
35 friend bool operator<(NotAnAllocator, NotAnAllocator) { return false; }
38 using P = std::pair<int, long>;
39 using PC = std::pair<const int, long>;
41 int main(int, char**)
44 // cannot deduce Key and T from nothing
45 std::multimap m; // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'multimap'}}
48 // cannot deduce Key and T from just (Compare)
49 std::multimap m(std::less<int>{});
50 // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'multimap'}}
53 // cannot deduce Key and T from just (Compare, Allocator)
54 std::multimap m(std::less<int>{}, std::allocator<PC>{});
55 // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'multimap'}}
58 // cannot deduce Key and T from just (Allocator)
59 std::multimap m(std::allocator<PC>{});
60 // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'multimap'}}
63 // refuse to rebind the allocator if Allocator::value_type is not exactly what we expect
64 const P arr[] = { {1,1L}, {2,2L}, {3,3L} };
65 std::multimap m(arr, arr + 3, std::allocator<P>());
66 // expected-error-re@map:* {{static assertion failed{{( due to requirement '.*')?}}{{.*}}Allocator::value_type must be same type as value_type}}
69 // cannot convert from some arbitrary unrelated type
70 NotAnAllocator a;
71 std::multimap m(a); // expected-error{{no viable constructor or deduction guide for deduction of template arguments of 'multimap'}}
74 // cannot deduce that the inner braced things should be std::pair and not something else
75 std::multimap m{ {1,1L}, {2,2L}, {3,3L} };
76 // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'multimap'}}
79 // cannot deduce that the inner braced things should be std::pair and not something else
80 std::multimap m({ {1,1L}, {2,2L}, {3,3L} }, std::less<int>());
81 // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'multimap'}}
84 // cannot deduce that the inner braced things should be std::pair and not something else
85 std::multimap m({ {1,1L}, {2,2L}, {3,3L} }, std::less<int>(), std::allocator<PC>());
86 // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'multimap'}}
89 // cannot deduce that the inner braced things should be std::pair and not something else
90 std::multimap m({ {1,1L}, {2,2L}, {3,3L} }, std::allocator<PC>());
91 // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'multimap'}}
94 // since we have parens, not braces, this deliberately does not find the initializer_list constructor
95 std::multimap m(P{1,1L});
96 // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'multimap'}}
99 // since we have parens, not braces, this deliberately does not find the initializer_list constructor
100 std::multimap m(PC{1,1L});
101 // expected-error@-1{{no viable constructor or deduction guide for deduction of template arguments of 'multimap'}}
104 return 0;