[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / associative / multiset / multiset.cons / deduct.pass.cpp
blob93bff1a41c667484b9e8cbe8e3ffdde099f8dc3c
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 // <set>
13 // template<class InputIterator,
14 // class Compare = less<iter-value-type<InputIterator>>,
15 // class Allocator = allocator<iter-value-type<InputIterator>>>
16 // multiset(InputIterator, InputIterator,
17 // Compare = Compare(), Allocator = Allocator())
18 // -> multiset<iter-value-type<InputIterator>, Compare, Allocator>;
19 // template<class Key, class Compare = less<Key>,
20 // class Allocator = allocator<Key>>
21 // multiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
22 // -> multiset<Key, Compare, Allocator>;
23 // template<class InputIterator, class Allocator>
24 // multiset(InputIterator, InputIterator, Allocator)
25 // -> multiset<iter-value-type<InputIterator>,
26 // less<iter-value-type<InputIterator>>, Allocator>;
27 // template<class Key, class Allocator>
28 // multiset(initializer_list<Key>, Allocator)
29 // -> multiset<Key, less<Key>, Allocator>;
31 // template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,
32 // class Allocator = allocator<ranges::range_value_t<R>>>
33 // multiset(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
34 // -> multiset<ranges::range_value_t<R>, Compare, Allocator>;
36 // template<ranges::input_range R, class Allocator>
37 // multiset(from_range_t, R&&, Allocator)
38 // -> multiset<ranges::range_value_t<R>, less<ranges::range_value_t<R>>, Allocator>;
40 #include <algorithm> // std::equal
41 #include <array>
42 #include <cassert>
43 #include <climits> // INT_MAX
44 #include <functional>
45 #include <set>
46 #include <type_traits>
48 #include "deduction_guides_sfinae_checks.h"
49 #include "test_allocator.h"
51 struct NotAnAllocator {
52 friend bool operator<(NotAnAllocator, NotAnAllocator) { return false; }
55 int main(int, char **) {
57 const int arr[] = { 1, 2, 1, INT_MAX, 3 };
58 std::multiset s(std::begin(arr), std::end(arr));
60 ASSERT_SAME_TYPE(decltype(s), std::multiset<int>);
61 const int expected_s[] = { 1, 1, 2, 3, INT_MAX };
62 assert(std::equal(s.begin(), s.end(), std::begin(expected_s),
63 std::end(expected_s)));
67 const int arr[] = { 1, 2, 1, INT_MAX, 3 };
68 std::multiset s(std::begin(arr), std::end(arr), std::greater<int>());
70 ASSERT_SAME_TYPE(decltype(s), std::multiset<int, std::greater<int> >);
71 const int expected_s[] = { INT_MAX, 3, 2, 1, 1 };
72 assert(std::equal(s.begin(), s.end(), std::begin(expected_s),
73 std::end(expected_s)));
77 const int arr[] = { 1, 2, 1, INT_MAX, 3 };
78 std::multiset s(std::begin(arr), std::end(arr), std::greater<int>(),
79 test_allocator<int>(0, 42));
81 ASSERT_SAME_TYPE(
82 decltype(s),
83 std::multiset<int, std::greater<int>, test_allocator<int> >);
84 const int expected_s[] = { INT_MAX, 3, 2, 1, 1 };
85 assert(std::equal(s.begin(), s.end(), std::begin(expected_s),
86 std::end(expected_s)));
87 assert(s.get_allocator().get_id() == 42);
91 std::multiset<long> source;
92 std::multiset s(source);
93 ASSERT_SAME_TYPE(decltype(s), std::multiset<long>);
94 assert(s.size() == 0);
98 std::multiset<long> source;
99 std::multiset s{ source }; // braces instead of parens
100 ASSERT_SAME_TYPE(decltype(s), std::multiset<long>);
101 assert(s.size() == 0);
105 std::multiset<long> source;
106 std::multiset s(source, std::multiset<long>::allocator_type());
107 ASSERT_SAME_TYPE(decltype(s), std::multiset<long>);
108 assert(s.size() == 0);
112 std::multiset s{ 1, 2, 1, INT_MAX, 3 };
114 ASSERT_SAME_TYPE(decltype(s), std::multiset<int>);
115 const int expected_s[] = { 1, 1, 2, 3, INT_MAX };
116 assert(std::equal(s.begin(), s.end(), std::begin(expected_s),
117 std::end(expected_s)));
121 std::multiset s({ 1, 2, 1, INT_MAX, 3 }, std::greater<int>());
123 ASSERT_SAME_TYPE(decltype(s), std::multiset<int, std::greater<int> >);
124 const int expected_s[] = { INT_MAX, 3, 2, 1, 1 };
125 assert(std::equal(s.begin(), s.end(), std::begin(expected_s),
126 std::end(expected_s)));
130 std::multiset s({ 1, 2, 1, INT_MAX, 3 }, std::greater<int>(),
131 test_allocator<int>(0, 43));
133 ASSERT_SAME_TYPE(
134 decltype(s),
135 std::multiset<int, std::greater<int>, test_allocator<int> >);
136 const int expected_s[] = { INT_MAX, 3, 2, 1, 1 };
137 assert(std::equal(s.begin(), s.end(), std::begin(expected_s),
138 std::end(expected_s)));
139 assert(s.get_allocator().get_id() == 43);
143 const int arr[] = { 1, 2, 1, INT_MAX, 3 };
144 std::multiset s(std::begin(arr), std::end(arr), test_allocator<int>(0, 44));
146 ASSERT_SAME_TYPE(decltype(s),
147 std::multiset<int, std::less<int>, test_allocator<int> >);
148 const int expected_s[] = { 1, 1, 2, 3, INT_MAX };
149 assert(std::equal(s.begin(), s.end(), std::begin(expected_s),
150 std::end(expected_s)));
151 assert(s.get_allocator().get_id() == 44);
155 std::multiset s({ 1, 2, 1, INT_MAX, 3 }, test_allocator<int>(0, 45));
157 ASSERT_SAME_TYPE(decltype(s),
158 std::multiset<int, std::less<int>, test_allocator<int> >);
159 const int expected_s[] = { 1, 1, 2, 3, INT_MAX };
160 assert(std::equal(s.begin(), s.end(), std::begin(expected_s),
161 std::end(expected_s)));
162 assert(s.get_allocator().get_id() == 45);
166 NotAnAllocator a;
167 std::multiset s{ a }; // multiset(initializer_list<NotAnAllocator>)
168 ASSERT_SAME_TYPE(decltype(s), std::multiset<NotAnAllocator>);
169 assert(s.size() == 1);
173 std::multiset<long> source;
174 std::multiset s{ source, source }; // multiset(initializer_list<multiset<long>>)
175 ASSERT_SAME_TYPE(decltype(s), std::multiset<std::multiset<long> >);
176 assert(s.size() == 2);
180 NotAnAllocator a;
181 std::multiset s{ a, a }; // multiset(initializer_list<NotAnAllocator>)
182 ASSERT_SAME_TYPE(decltype(s), std::multiset<NotAnAllocator>);
183 assert(s.size() == 2);
187 int source[3] = { 3, 4, 5 };
188 std::multiset s(source, source + 3); // multiset(InputIterator, InputIterator)
189 ASSERT_SAME_TYPE(decltype(s), std::multiset<int>);
190 assert(s.size() == 3);
194 int source[3] = { 3, 4, 5 };
195 std::multiset s{ source, source + 3 }; // multiset(initializer_list<int*>)
196 ASSERT_SAME_TYPE(decltype(s), std::multiset<int *>);
197 assert(s.size() == 2);
200 #if TEST_STD_VER >= 23
202 using Range = std::array<int, 0>;
203 using Comp = std::greater<int>;
204 using DefaultComp = std::less<int>;
205 using Alloc = test_allocator<int>;
207 { // (from_range, range)
208 std::multiset c(std::from_range, Range());
209 static_assert(std::is_same_v<decltype(c), std::multiset<int>>);
212 { // (from_range, range, comp)
213 std::multiset c(std::from_range, Range(), Comp());
214 static_assert(std::is_same_v<decltype(c), std::multiset<int, Comp>>);
217 { // (from_range, range, comp, alloc)
218 std::multiset c(std::from_range, Range(), Comp(), Alloc());
219 static_assert(std::is_same_v<decltype(c), std::multiset<int, Comp, Alloc>>);
222 { // (from_range, range, alloc)
223 std::multiset c(std::from_range, Range(), Alloc());
224 static_assert(std::is_same_v<decltype(c), std::multiset<int, DefaultComp, Alloc>>);
227 #endif
229 AssociativeContainerDeductionGuidesSfinaeAway<std::multiset, std::multiset<int>>();
231 return 0;