1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <algorithm>
11
12 // template<class ForwardIterator1, class ForwardIterator2>
13 // bool
14 // is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
15 // ForwardIterator2 first2);
16
17 #include <algorithm>
18 #include <cassert>
19
20 #include "test_iterators.h"
21
22 #include "test_macros.h"
23
main()24 int main()
25 {
26 {
27 const int ia[] = {0};
28 const int ib[] = {0};
29 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
30 assert(std::is_permutation(forward_iterator<const int*>(ia),
31 forward_iterator<const int*>(ia + 0),
32 forward_iterator<const int*>(ib)) == true);
33 #if TEST_STD_VER >= 14
34 assert(std::is_permutation(forward_iterator<const int*>(ia),
35 forward_iterator<const int*>(ia + 0),
36 forward_iterator<const int*>(ib),
37 forward_iterator<const int*>(ib + 0)) == true);
38 #endif
39 assert(std::is_permutation(forward_iterator<const int*>(ia),
40 forward_iterator<const int*>(ia + sa),
41 forward_iterator<const int*>(ib)) == true);
42 #if TEST_STD_VER >= 14
43 assert(std::is_permutation(forward_iterator<const int*>(ia),
44 forward_iterator<const int*>(ia + sa),
45 forward_iterator<const int*>(ib),
46 forward_iterator<const int*>(ib + sa)) == true);
47 assert(std::is_permutation(forward_iterator<const int*>(ia),
48 forward_iterator<const int*>(ia + sa),
49 forward_iterator<const int*>(ib),
50 forward_iterator<const int*>(ib + sa - 1)) == false);
51 #endif
52 }
53 {
54 const int ia[] = {0};
55 const int ib[] = {1};
56 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
57 assert(std::is_permutation(forward_iterator<const int*>(ia),
58 forward_iterator<const int*>(ia + sa),
59 forward_iterator<const int*>(ib)) == false);
60 #if TEST_STD_VER >= 14
61 assert(std::is_permutation(forward_iterator<const int*>(ia),
62 forward_iterator<const int*>(ia + sa),
63 forward_iterator<const int*>(ib),
64 forward_iterator<const int*>(ib + sa)) == false);
65 #endif
66 }
67
68 {
69 const int ia[] = {0, 0};
70 const int ib[] = {0, 0};
71 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
72 assert(std::is_permutation(forward_iterator<const int*>(ia),
73 forward_iterator<const int*>(ia + sa),
74 forward_iterator<const int*>(ib)) == true);
75 #if TEST_STD_VER >= 14
76 assert(std::is_permutation(forward_iterator<const int*>(ia),
77 forward_iterator<const int*>(ia + sa),
78 forward_iterator<const int*>(ib),
79 forward_iterator<const int*>(ib + sa)) == true);
80 assert(std::is_permutation(forward_iterator<const int*>(ia),
81 forward_iterator<const int*>(ia + sa),
82 forward_iterator<const int*>(ib),
83 forward_iterator<const int*>(ib + sa - 1)) == false);
84 #endif
85 }
86 {
87 const int ia[] = {0, 0};
88 const int ib[] = {0, 1};
89 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
90 assert(std::is_permutation(forward_iterator<const int*>(ia),
91 forward_iterator<const int*>(ia + sa),
92 forward_iterator<const int*>(ib)) == false);
93 #if TEST_STD_VER >= 14
94 assert(std::is_permutation(forward_iterator<const int*>(ia),
95 forward_iterator<const int*>(ia + sa),
96 forward_iterator<const int*>(ib),
97 forward_iterator<const int*>(ib + sa)) == false);
98 #endif
99 }
100 {
101 const int ia[] = {0, 0};
102 const int ib[] = {1, 0};
103 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
104 assert(std::is_permutation(forward_iterator<const int*>(ia),
105 forward_iterator<const int*>(ia + sa),
106 forward_iterator<const int*>(ib)) == false);
107 #if TEST_STD_VER >= 14
108 assert(std::is_permutation(forward_iterator<const int*>(ia),
109 forward_iterator<const int*>(ia + sa),
110 forward_iterator<const int*>(ib),
111 forward_iterator<const int*>(ib + sa)) == false);
112 #endif
113 }
114 {
115 const int ia[] = {0, 0};
116 const int ib[] = {1, 1};
117 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
118 assert(std::is_permutation(forward_iterator<const int*>(ia),
119 forward_iterator<const int*>(ia + sa),
120 forward_iterator<const int*>(ib)) == false);
121 #if TEST_STD_VER >= 14
122 assert(std::is_permutation(forward_iterator<const int*>(ia),
123 forward_iterator<const int*>(ia + sa),
124 forward_iterator<const int*>(ib),
125 forward_iterator<const int*>(ib + sa)) == false);
126 #endif
127 }
128 {
129 const int ia[] = {0, 1};
130 const int ib[] = {0, 0};
131 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
132 assert(std::is_permutation(forward_iterator<const int*>(ia),
133 forward_iterator<const int*>(ia + sa),
134 forward_iterator<const int*>(ib)) == false);
135 #if TEST_STD_VER >= 14
136 assert(std::is_permutation(forward_iterator<const int*>(ia),
137 forward_iterator<const int*>(ia + sa),
138 forward_iterator<const int*>(ib),
139 forward_iterator<const int*>(ib + sa)) == false);
140 #endif
141 }
142 {
143 const int ia[] = {0, 1};
144 const int ib[] = {0, 1};
145 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
146 assert(std::is_permutation(forward_iterator<const int*>(ia),
147 forward_iterator<const int*>(ia + sa),
148 forward_iterator<const int*>(ib)) == true);
149 #if TEST_STD_VER >= 14
150 assert(std::is_permutation(forward_iterator<const int*>(ia),
151 forward_iterator<const int*>(ia + sa),
152 forward_iterator<const int*>(ib),
153 forward_iterator<const int*>(ib + sa)) == true);
154 assert(std::is_permutation(forward_iterator<const int*>(ia),
155 forward_iterator<const int*>(ia + sa),
156 forward_iterator<const int*>(ib),
157 forward_iterator<const int*>(ib + sa - 1)) == false);
158 #endif
159 }
160 {
161 const int ia[] = {0, 1};
162 const int ib[] = {1, 0};
163 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
164 assert(std::is_permutation(forward_iterator<const int*>(ia),
165 forward_iterator<const int*>(ia + sa),
166 forward_iterator<const int*>(ib)) == true);
167 #if TEST_STD_VER >= 14
168 assert(std::is_permutation(forward_iterator<const int*>(ia),
169 forward_iterator<const int*>(ia + sa),
170 forward_iterator<const int*>(ib),
171 forward_iterator<const int*>(ib + sa)) == true);
172 #endif
173 }
174 {
175 const int ia[] = {0, 1};
176 const int ib[] = {1, 1};
177 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
178 assert(std::is_permutation(forward_iterator<const int*>(ia),
179 forward_iterator<const int*>(ia + sa),
180 forward_iterator<const int*>(ib)) == false);
181 #if TEST_STD_VER >= 14
182 assert(std::is_permutation(forward_iterator<const int*>(ia),
183 forward_iterator<const int*>(ia + sa),
184 forward_iterator<const int*>(ib),
185 forward_iterator<const int*>(ib + sa)) == false);
186 #endif
187 }
188 {
189 const int ia[] = {1, 0};
190 const int ib[] = {0, 0};
191 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
192 assert(std::is_permutation(forward_iterator<const int*>(ia),
193 forward_iterator<const int*>(ia + sa),
194 forward_iterator<const int*>(ib)) == false);
195 #if TEST_STD_VER >= 14
196 assert(std::is_permutation(forward_iterator<const int*>(ia),
197 forward_iterator<const int*>(ia + sa),
198 forward_iterator<const int*>(ib),
199 forward_iterator<const int*>(ib + sa)) == false);
200 #endif
201 }
202 {
203 const int ia[] = {1, 0};
204 const int ib[] = {0, 1};
205 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
206 assert(std::is_permutation(forward_iterator<const int*>(ia),
207 forward_iterator<const int*>(ia + sa),
208 forward_iterator<const int*>(ib)) == true);
209 #if TEST_STD_VER >= 14
210 assert(std::is_permutation(forward_iterator<const int*>(ia),
211 forward_iterator<const int*>(ia + sa),
212 forward_iterator<const int*>(ib),
213 forward_iterator<const int*>(ib + sa)) == true);
214 #endif
215 }
216 {
217 const int ia[] = {1, 0};
218 const int ib[] = {1, 0};
219 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
220 assert(std::is_permutation(forward_iterator<const int*>(ia),
221 forward_iterator<const int*>(ia + sa),
222 forward_iterator<const int*>(ib)) == true);
223 #if TEST_STD_VER >= 14
224 assert(std::is_permutation(forward_iterator<const int*>(ia),
225 forward_iterator<const int*>(ia + sa),
226 forward_iterator<const int*>(ib),
227 forward_iterator<const int*>(ib + sa)) == true);
228 #endif
229 }
230 {
231 const int ia[] = {1, 0};
232 const int ib[] = {1, 1};
233 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
234 assert(std::is_permutation(forward_iterator<const int*>(ia),
235 forward_iterator<const int*>(ia + sa),
236 forward_iterator<const int*>(ib)) == false);
237 #if TEST_STD_VER >= 14
238 assert(std::is_permutation(forward_iterator<const int*>(ia),
239 forward_iterator<const int*>(ia + sa),
240 forward_iterator<const int*>(ib),
241 forward_iterator<const int*>(ib + sa)) == false);
242 #endif
243 }
244 {
245 const int ia[] = {1, 1};
246 const int ib[] = {0, 0};
247 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
248 assert(std::is_permutation(forward_iterator<const int*>(ia),
249 forward_iterator<const int*>(ia + sa),
250 forward_iterator<const int*>(ib)) == false);
251 #if TEST_STD_VER >= 14
252 assert(std::is_permutation(forward_iterator<const int*>(ia),
253 forward_iterator<const int*>(ia + sa),
254 forward_iterator<const int*>(ib),
255 forward_iterator<const int*>(ib + sa)) == false);
256 #endif
257 }
258 {
259 const int ia[] = {1, 1};
260 const int ib[] = {0, 1};
261 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
262 assert(std::is_permutation(forward_iterator<const int*>(ia),
263 forward_iterator<const int*>(ia + sa),
264 forward_iterator<const int*>(ib)) == false);
265 #if TEST_STD_VER >= 14
266 assert(std::is_permutation(forward_iterator<const int*>(ia),
267 forward_iterator<const int*>(ia + sa),
268 forward_iterator<const int*>(ib),
269 forward_iterator<const int*>(ib + sa)) == false);
270 #endif
271 }
272 {
273 const int ia[] = {1, 1};
274 const int ib[] = {1, 0};
275 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
276 assert(std::is_permutation(forward_iterator<const int*>(ia),
277 forward_iterator<const int*>(ia + sa),
278 forward_iterator<const int*>(ib)) == false);
279 #if TEST_STD_VER >= 14
280 assert(std::is_permutation(forward_iterator<const int*>(ia),
281 forward_iterator<const int*>(ia + sa),
282 forward_iterator<const int*>(ib),
283 forward_iterator<const int*>(ib + sa)) == false);
284 #endif
285 }
286 {
287 const int ia[] = {1, 1};
288 const int ib[] = {1, 1};
289 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
290 assert(std::is_permutation(forward_iterator<const int*>(ia),
291 forward_iterator<const int*>(ia + sa),
292 forward_iterator<const int*>(ib)) == true);
293 #if TEST_STD_VER >= 14
294 assert(std::is_permutation(forward_iterator<const int*>(ia),
295 forward_iterator<const int*>(ia + sa),
296 forward_iterator<const int*>(ib),
297 forward_iterator<const int*>(ib + sa)) == true);
298 #endif
299 }
300
301 {
302 const int ia[] = {0, 0, 0};
303 const int ib[] = {1, 0, 0};
304 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
305 assert(std::is_permutation(forward_iterator<const int*>(ia),
306 forward_iterator<const int*>(ia + sa),
307 forward_iterator<const int*>(ib)) == false);
308 #if TEST_STD_VER >= 14
309 assert(std::is_permutation(forward_iterator<const int*>(ia),
310 forward_iterator<const int*>(ia + sa),
311 forward_iterator<const int*>(ib),
312 forward_iterator<const int*>(ib + sa)) == false);
313 #endif
314 }
315 {
316 const int ia[] = {0, 0, 0};
317 const int ib[] = {1, 0, 1};
318 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
319 assert(std::is_permutation(forward_iterator<const int*>(ia),
320 forward_iterator<const int*>(ia + sa),
321 forward_iterator<const int*>(ib)) == false);
322 #if TEST_STD_VER >= 14
323 assert(std::is_permutation(forward_iterator<const int*>(ia),
324 forward_iterator<const int*>(ia + sa),
325 forward_iterator<const int*>(ib),
326 forward_iterator<const int*>(ib + sa)) == false);
327 #endif
328 }
329 {
330 const int ia[] = {0, 0, 0};
331 const int ib[] = {1, 0, 2};
332 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
333 assert(std::is_permutation(forward_iterator<const int*>(ia),
334 forward_iterator<const int*>(ia + sa),
335 forward_iterator<const int*>(ib)) == false);
336 #if TEST_STD_VER >= 14
337 assert(std::is_permutation(forward_iterator<const int*>(ia),
338 forward_iterator<const int*>(ia + sa),
339 forward_iterator<const int*>(ib),
340 forward_iterator<const int*>(ib + sa)) == false);
341 #endif
342 }
343 {
344 const int ia[] = {0, 0, 0};
345 const int ib[] = {1, 1, 0};
346 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
347 assert(std::is_permutation(forward_iterator<const int*>(ia),
348 forward_iterator<const int*>(ia + sa),
349 forward_iterator<const int*>(ib)) == false);
350 #if TEST_STD_VER >= 14
351 assert(std::is_permutation(forward_iterator<const int*>(ia),
352 forward_iterator<const int*>(ia + sa),
353 forward_iterator<const int*>(ib),
354 forward_iterator<const int*>(ib + sa)) == false);
355 #endif
356 }
357 {
358 const int ia[] = {0, 0, 0};
359 const int ib[] = {1, 1, 1};
360 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
361 assert(std::is_permutation(forward_iterator<const int*>(ia),
362 forward_iterator<const int*>(ia + sa),
363 forward_iterator<const int*>(ib)) == false);
364 #if TEST_STD_VER >= 14
365 assert(std::is_permutation(forward_iterator<const int*>(ia),
366 forward_iterator<const int*>(ia + sa),
367 forward_iterator<const int*>(ib),
368 forward_iterator<const int*>(ib + sa)) == false);
369 #endif
370 }
371 {
372 const int ia[] = {0, 0, 0};
373 const int ib[] = {1, 1, 2};
374 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
375 assert(std::is_permutation(forward_iterator<const int*>(ia),
376 forward_iterator<const int*>(ia + sa),
377 forward_iterator<const int*>(ib)) == false);
378 #if TEST_STD_VER >= 14
379 assert(std::is_permutation(forward_iterator<const int*>(ia),
380 forward_iterator<const int*>(ia + sa),
381 forward_iterator<const int*>(ib),
382 forward_iterator<const int*>(ib + sa)) == false);
383 #endif
384 }
385 {
386 const int ia[] = {0, 0, 0};
387 const int ib[] = {1, 2, 0};
388 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
389 assert(std::is_permutation(forward_iterator<const int*>(ia),
390 forward_iterator<const int*>(ia + sa),
391 forward_iterator<const int*>(ib)) == false);
392 #if TEST_STD_VER >= 14
393 assert(std::is_permutation(forward_iterator<const int*>(ia),
394 forward_iterator<const int*>(ia + sa),
395 forward_iterator<const int*>(ib),
396 forward_iterator<const int*>(ib + sa)) == false);
397 #endif
398 }
399 {
400 const int ia[] = {0, 0, 0};
401 const int ib[] = {1, 2, 1};
402 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
403 assert(std::is_permutation(forward_iterator<const int*>(ia),
404 forward_iterator<const int*>(ia + sa),
405 forward_iterator<const int*>(ib)) == false);
406 #if TEST_STD_VER >= 14
407 assert(std::is_permutation(forward_iterator<const int*>(ia),
408 forward_iterator<const int*>(ia + sa),
409 forward_iterator<const int*>(ib),
410 forward_iterator<const int*>(ib + sa)) == false);
411 #endif
412 }
413 {
414 const int ia[] = {0, 0, 0};
415 const int ib[] = {1, 2, 2};
416 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
417 assert(std::is_permutation(forward_iterator<const int*>(ia),
418 forward_iterator<const int*>(ia + sa),
419 forward_iterator<const int*>(ib)) == false);
420 #if TEST_STD_VER >= 14
421 assert(std::is_permutation(forward_iterator<const int*>(ia),
422 forward_iterator<const int*>(ia + sa),
423 forward_iterator<const int*>(ib),
424 forward_iterator<const int*>(ib + sa)) == false);
425 #endif
426 }
427 {
428 const int ia[] = {0, 0, 1};
429 const int ib[] = {1, 0, 0};
430 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
431 assert(std::is_permutation(forward_iterator<const int*>(ia),
432 forward_iterator<const int*>(ia + sa),
433 forward_iterator<const int*>(ib)) == true);
434 #if TEST_STD_VER >= 14
435 assert(std::is_permutation(forward_iterator<const int*>(ia),
436 forward_iterator<const int*>(ia + sa),
437 forward_iterator<const int*>(ib),
438 forward_iterator<const int*>(ib + sa)) == true);
439 assert(std::is_permutation(forward_iterator<const int*>(ia),
440 forward_iterator<const int*>(ia + sa),
441 forward_iterator<const int*>(ib),
442 forward_iterator<const int*>(ib + sa - 1)) == false);
443 #endif
444 }
445 {
446 const int ia[] = {0, 0, 1};
447 const int ib[] = {1, 0, 1};
448 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
449 assert(std::is_permutation(forward_iterator<const int*>(ia),
450 forward_iterator<const int*>(ia + sa),
451 forward_iterator<const int*>(ib)) == false);
452 #if TEST_STD_VER >= 14
453 assert(std::is_permutation(forward_iterator<const int*>(ia),
454 forward_iterator<const int*>(ia + sa),
455 forward_iterator<const int*>(ib),
456 forward_iterator<const int*>(ib + sa)) == false);
457 #endif
458 }
459 {
460 const int ia[] = {0, 1, 2};
461 const int ib[] = {1, 0, 2};
462 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
463 assert(std::is_permutation(forward_iterator<const int*>(ia),
464 forward_iterator<const int*>(ia + sa),
465 forward_iterator<const int*>(ib)) == true);
466 #if TEST_STD_VER >= 14
467 assert(std::is_permutation(forward_iterator<const int*>(ia),
468 forward_iterator<const int*>(ia + sa),
469 forward_iterator<const int*>(ib),
470 forward_iterator<const int*>(ib + sa)) == true);
471 assert(std::is_permutation(forward_iterator<const int*>(ia),
472 forward_iterator<const int*>(ia + sa),
473 forward_iterator<const int*>(ib),
474 forward_iterator<const int*>(ib + sa - 1)) == false);
475 #endif
476 }
477 {
478 const int ia[] = {0, 1, 2};
479 const int ib[] = {1, 2, 0};
480 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
481 assert(std::is_permutation(forward_iterator<const int*>(ia),
482 forward_iterator<const int*>(ia + sa),
483 forward_iterator<const int*>(ib)) == true);
484 #if TEST_STD_VER >= 14
485 assert(std::is_permutation(forward_iterator<const int*>(ia),
486 forward_iterator<const int*>(ia + sa),
487 forward_iterator<const int*>(ib),
488 forward_iterator<const int*>(ib + sa)) == true);
489 assert(std::is_permutation(forward_iterator<const int*>(ia),
490 forward_iterator<const int*>(ia + sa),
491 forward_iterator<const int*>(ib),
492 forward_iterator<const int*>(ib + sa - 1)) == false);
493 #endif
494 }
495 {
496 const int ia[] = {0, 1, 2};
497 const int ib[] = {2, 1, 0};
498 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
499 assert(std::is_permutation(forward_iterator<const int*>(ia),
500 forward_iterator<const int*>(ia + sa),
501 forward_iterator<const int*>(ib)) == true);
502 #if TEST_STD_VER >= 14
503 assert(std::is_permutation(forward_iterator<const int*>(ia),
504 forward_iterator<const int*>(ia + sa),
505 forward_iterator<const int*>(ib),
506 forward_iterator<const int*>(ib + sa)) == true);
507 assert(std::is_permutation(forward_iterator<const int*>(ia),
508 forward_iterator<const int*>(ia + sa),
509 forward_iterator<const int*>(ib),
510 forward_iterator<const int*>(ib + sa - 1)) == false);
511 #endif
512 }
513 {
514 const int ia[] = {0, 1, 2};
515 const int ib[] = {2, 0, 1};
516 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
517 assert(std::is_permutation(forward_iterator<const int*>(ia),
518 forward_iterator<const int*>(ia + sa),
519 forward_iterator<const int*>(ib)) == true);
520 #if TEST_STD_VER >= 14
521 assert(std::is_permutation(forward_iterator<const int*>(ia),
522 forward_iterator<const int*>(ia + sa),
523 forward_iterator<const int*>(ib),
524 forward_iterator<const int*>(ib + sa)) == true);
525 assert(std::is_permutation(forward_iterator<const int*>(ia),
526 forward_iterator<const int*>(ia + sa),
527 forward_iterator<const int*>(ib),
528 forward_iterator<const int*>(ib + sa - 1)) == false);
529 #endif
530 }
531 {
532 const int ia[] = {0, 0, 1};
533 const int ib[] = {1, 0, 1};
534 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
535 assert(std::is_permutation(forward_iterator<const int*>(ia),
536 forward_iterator<const int*>(ia + sa),
537 forward_iterator<const int*>(ib)) == false);
538 #if TEST_STD_VER >= 14
539 assert(std::is_permutation(forward_iterator<const int*>(ia),
540 forward_iterator<const int*>(ia + sa),
541 forward_iterator<const int*>(ib),
542 forward_iterator<const int*>(ib + sa)) == false);
543 #endif
544 }
545 {
546 const int ia[] = {0, 0, 1};
547 const int ib[] = {1, 0, 0};
548 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
549 assert(std::is_permutation(forward_iterator<const int*>(ia),
550 forward_iterator<const int*>(ia + sa),
551 forward_iterator<const int*>(ib)) == true);
552 #if TEST_STD_VER >= 14
553 assert(std::is_permutation(forward_iterator<const int*>(ia),
554 forward_iterator<const int*>(ia + sa),
555 forward_iterator<const int*>(ib),
556 forward_iterator<const int*>(ib + sa)) == true);
557 assert(std::is_permutation(forward_iterator<const int*>(ia),
558 forward_iterator<const int*>(ia + sa),
559 forward_iterator<const int*>(ib + 1),
560 forward_iterator<const int*>(ib + sa)) == false);
561 assert(std::is_permutation(forward_iterator<const int*>(ia),
562 forward_iterator<const int*>(ia + sa),
563 forward_iterator<const int*>(ib),
564 forward_iterator<const int*>(ib + sa - 1)) == false);
565 #endif
566 }
567 {
568 const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
569 const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 2};
570 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
571 assert(std::is_permutation(forward_iterator<const int*>(ia),
572 forward_iterator<const int*>(ia + sa),
573 forward_iterator<const int*>(ib)) == true);
574 #if TEST_STD_VER >= 14
575 assert(std::is_permutation(forward_iterator<const int*>(ia),
576 forward_iterator<const int*>(ia + sa),
577 forward_iterator<const int*>(ib),
578 forward_iterator<const int*>(ib + sa)) == true);
579 assert(std::is_permutation(forward_iterator<const int*>(ia),
580 forward_iterator<const int*>(ia + sa),
581 forward_iterator<const int*>(ib + 1 ),
582 forward_iterator<const int*>(ib + sa)) == false);
583 assert(std::is_permutation(forward_iterator<const int*>(ia),
584 forward_iterator<const int*>(ia + sa),
585 forward_iterator<const int*>(ib),
586 forward_iterator<const int*>(ib + sa - 1)) == false);
587 #endif
588 }
589 {
590 const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
591 const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 0};
592 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
593 assert(std::is_permutation(forward_iterator<const int*>(ia),
594 forward_iterator<const int*>(ia + sa),
595 forward_iterator<const int*>(ib)) == false);
596 #if TEST_STD_VER >= 14
597 assert(std::is_permutation(forward_iterator<const int*>(ia),
598 forward_iterator<const int*>(ia + sa),
599 forward_iterator<const int*>(ib),
600 forward_iterator<const int*>(ib + sa)) == false);
601 #endif
602 }
603 }
604