File: algorithm

package info (click to toggle)
cppreference-doc 20170409-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 259,868 kB
  • sloc: xml: 570,184; python: 1,923; php: 520; makefile: 167; sh: 25; cpp: 9; ansic: 9
file content (689 lines) | stat: -rw-r--r-- 23,981 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
/*  Copyright (C) 2015  Povilas Kanapickas <povilas@radix.lt>

    This file is part of cppreference-doc

    This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
    Unported License. To view a copy of this license, visit
    http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
    Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3 or
    any later version published by the Free Software Foundation; with no
    Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
*/
#ifndef CPPREFERENCE_ALGORITHM_H
#define CPPREFERENCE_ALGORITHM_H

#if CPPREFERENCE_STDVER >= 2011
#include <initializer_list>
#endif

namespace std {

#if CPPREFERENCE_STDVER >= 2011
template<class InputIt, class UnaryPredicate>
bool all_of(InputIt first, InputIt last, UnaryPredicate p);

template<class InputIt, class UnaryPredicate>
bool any_of(InputIt first, InputIt last, UnaryPredicate p);

template<class InputIt, class UnaryPredicate>
bool none_of(InputIt first, InputIt last, UnaryPredicate p);
#endif

template<class InputIt, class UnaryFunction >
UnaryFunction for_each(InputIt first, InputIt last, UnaryFunction f);

template<class InputIt, class T >
typename iterator_traits<InputIt>::difference_type
count(InputIt first, InputIt last, const T& value);

template<class InputIt, class UnaryPredicate >
typename iterator_traits<InputIt>::difference_type
count_if(InputIt first, InputIt last, UnaryPredicate p);

template<class InputIt1, class InputIt2 >
std::pair<InputIt1, InputIt2>
mismatch(InputIt1 first1, InputIt1 last1,
         InputIt2 first2);

template<class InputIt1, class InputIt2, class BinaryPredicate >
std::pair<InputIt1, InputIt2>
mismatch(InputIt1 first1, InputIt1 last1,
         InputIt2 first2,
         BinaryPredicate p);

#if CPPREFERENCE_STDVER >= 2014
template<class InputIt1, class InputIt2 >
std::pair<InputIt1, InputIt2>
mismatch(InputIt1 first1, InputIt1 last1,
         InputIt2 first2, InputIt2 last2);

template<class InputIt1, class InputIt2, class BinaryPredicate >
std::pair<InputIt1, InputIt2>
mismatch(InputIt1 first1, InputIt1 last1,
         InputIt2 first2, InputIt2 last2,
         BinaryPredicate p);
#endif

template<class InputIt1, class InputIt2 >
bool equal(InputIt1 first1, InputIt1 last1,
           InputIt2 first2);

template<class InputIt1, class InputIt2, class BinaryPredicate >
bool equal(InputIt1 first1, InputIt1 last1,
           InputIt2 first2, BinaryPredicate p);

#if CPPREFERENCE_STDVER >= 2014
template<class InputIt1, class InputIt2 >
bool equal(InputIt1 first1, InputIt1 last1,
           InputIt2 first2, InputIt2 last2);

template<class InputIt1, class InputIt2, class BinaryPredicate >
bool equal(InputIt1 first1, InputIt1 last1,
           InputIt2 first2, InputIt2 last2,
           BinaryPredicate p);
#endif

template<class InputIt, class T >
InputIt find(InputIt first, InputIt last, const T& value);

template<class InputIt, class UnaryPredicate >
InputIt find_if(InputIt first, InputIt last,
                UnaryPredicate p);

#if CPPREFERENCE_STDVER >= 2011
template<class InputIt, class UnaryPredicate >
InputIt find_if_not(InputIt first, InputIt last,
                    UnaryPredicate q);
#endif

template<class ForwardIt1, class ForwardIt2 >
ForwardIt1 find_end(ForwardIt1 first, ForwardIt1 last,
                    ForwardIt2 s_first, ForwardIt2 s_last);

template<class ForwardIt1, class ForwardIt2, class BinaryPredicate >
ForwardIt1 find_end(ForwardIt1 first, ForwardIt1 last,
                    ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p);

#if CPPREFERENCE_STDVER >= 2011
template<class InputIt, class ForwardIt >
InputIt find_first_of(InputIt first, InputIt last,
                      ForwardIt s_first, ForwardIt s_last);

template<class InputIt, class ForwardIt, class BinaryPredicate >
InputIt find_first_of(InputIt first, InputIt last,
                      ForwardIt s_first, ForwardIt s_last, BinaryPredicate p);
#else
template<class ForwardIt1, class ForwardIt2 >
ForwardIt1 find_first_of(ForwardIt1 first, ForwardIt1 last,
                         ForwardIt2 s_first, ForwardIt2 s_last);

template<class ForwardIt1, class ForwardIt2, class BinaryPredicate >
ForwardIt1 find_first_of(ForwardIt1 first, ForwardIt1 last,
                         ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p);
#endif

template<class ForwardIt >
ForwardIt adjacent_find(ForwardIt first, ForwardIt last);

template<class ForwardIt, class BinaryPredicate>
ForwardIt adjacent_find(ForwardIt first, ForwardIt last, BinaryPredicate p);

template<class ForwardIt1, class ForwardIt2 >
ForwardIt1 search(ForwardIt1 first, ForwardIt1 last,
                  ForwardIt2 s_first, ForwardIt2 s_last);

template<class ForwardIt1, class ForwardIt2, class BinaryPredicate >
ForwardIt1 search(ForwardIt1 first, ForwardIt1 last,
                  ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p);

template<class ForwardIt, class Size, class T >
ForwardIt search_n(ForwardIt first, ForwardIt last, Size count, const T& value);

template<class ForwardIt, class Size, class T, class BinaryPredicate >
ForwardIt search_n(ForwardIt first, ForwardIt last, Size count, const T& value,
                   BinaryPredicate p);

template<class InputIt, class OutputIt >
OutputIt copy(InputIt first, InputIt last, OutputIt d_first);

#if CPPREFERENCE_STDVER >= 2011
template<class InputIt, class OutputIt, class UnaryPredicate >
OutputIt copy_if(InputIt first, InputIt last,
                 OutputIt d_first,
                 UnaryPredicate pred);
#endif

#if CPPREFERENCE_STDVER >= 2011
template<class InputIt, class Size, class OutputIt >
OutputIt copy_n(InputIt first, Size count, OutputIt result);
#endif

template<class BidirIt1, class BidirIt2 >
BidirIt2 copy_backward(BidirIt1 first, BidirIt1 last, BidirIt2 d_last);

#if CPPREFERENCE_STDVER >= 2011
template<class InputIt, class OutputIt >
OutputIt move(InputIt first, InputIt last, OutputIt d_first);
#endif

#if CPPREFERENCE_STDVER >= 2011
template<class InputIt, class OutputIt >
OutputIt move(InputIt first, InputIt last, OutputIt d_first);
#endif

template<class ForwardIt, class T >
void fill(ForwardIt first, ForwardIt last, const T& value);

#if CPPREFERENCE_STDVER >= 2011
template<class OutputIt, class Size, class T >
OutputIt fill_n(OutputIt first, Size count, const T& value);
#else
template<class OutputIt, class Size, class T >
void fill_n(OutputIt first, Size count, const T& value);
#endif

template<class InputIt, class OutputIt, class UnaryOperation >
OutputIt transform(InputIt first1, InputIt last1, OutputIt d_first,
                   UnaryOperation unary_op);

template<class InputIt1, class InputIt2, class OutputIt, class BinaryOperation >
OutputIt transform(InputIt1 first1, InputIt1 last1, InputIt2 first2,
                   OutputIt d_first, BinaryOperation binary_op);

template<class ForwardIt, class Generator >
void generate(ForwardIt first, ForwardIt last, Generator g);

#if CPPREFERENCE_STDVER >= 2011
template<class OutputIt, class Size, class Generator >
OutputIt generate_n(OutputIt first, Size count, Generator g);
#else
template<class OutputIt, class Size, class Generator >
void generate_n(OutputIt first, Size count, Generator g);
#endif

template<class ForwardIt, class T >
ForwardIt remove(ForwardIt first, ForwardIt last, const T& value);

template<class ForwardIt, class UnaryPredicate >
ForwardIt remove_if(ForwardIt first, ForwardIt last, UnaryPredicate p);

template<class InputIt, class OutputIt, class T >
OutputIt remove_copy(InputIt first, InputIt last, OutputIt d_first,
                     const T& value);

template<class InputIt, class OutputIt, class UnaryPredicate >
OutputIt remove_copy_if(InputIt first, InputIt last, OutputIt d_first,
                        UnaryPredicate p);

template<class InputIt, class OutputIt, class UnaryPredicate >
OutputIt remove_copy_if(InputIt first, InputIt last, OutputIt d_first,
                        UnaryPredicate p);

template<class ForwardIt, class UnaryPredicate, class T >
void replace_if(ForwardIt first, ForwardIt last,
                UnaryPredicate p, const T& new_value);

template<class InputIt, class OutputIt, class T >
OutputIt replace_copy(InputIt first, InputIt last, OutputIt d_first,
                      const T& old_value, const T& new_value);

template<class InputIt, class OutputIt, class UnaryPredicate, class T >
OutputIt replace_copy_if(InputIt first, InputIt last, OutputIt d_first,
                         UnaryPredicate p, const T& new_value);

// defined in <utility> in C++11
#if CPPREFERENCE_STDVER >= 2011
template<class T >
void swap(T& a, T& b);
#endif

template<class ForwardIt1, class ForwardIt2 >
ForwardIt2 swap_ranges(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2);

template<class ForwardIt1, class ForwardIt2 >
void iter_swap(ForwardIt1 a, ForwardIt2 b);

template<class BidirIt >
void reverse(BidirIt first, BidirIt last);

template<class BidirIt, class OutputIt >
OutputIt reverse_copy(BidirIt first, BidirIt last, OutputIt d_first);

#if CPPREFERENCE_STDVER >= 2011
template<class ForwardIt >
ForwardIt rotate(ForwardIt first, ForwardIt n_first, ForwardIt last);
#else
template<class ForwardIt >
void rotate(ForwardIt first, ForwardIt n_first, ForwardIt last);
#endif

template<class ForwardIt, class OutputIt >
OutputIt rotate_copy(ForwardIt first, ForwardIt n_first,
                     ForwardIt last, OutputIt d_first);

#if CPPREFERENCE_STDVER <2017
// deprecated in C++14
template<class RandomIt >
void random_shuffle(RandomIt first, RandomIt last);
#endif

#if CPPREFERENCE_STDVER <2011
template<class RandomIt, class RandomFunc >
void random_shuffle(RandomIt first, RandomIt last, RandomFunc&& r);
#elif CPPREFERENCE_STDVER >= 2011 && CPPREFERENCE_STDVER <2017
// deprecated in C++14
template<class RandomIt, class RandomFunc >
void random_shuffle(RandomIt first, RandomIt last, RandomFunc& r);
#endif

#if CPPREFERENCE_STDVER >= 2011
template<class RandomIt, class URNG >
void shuffle(RandomIt first, RandomIt last, URNG&& g);
#endif

template<class ForwardIt >
ForwardIt unique(ForwardIt first, ForwardIt last);

template<class ForwardIt, class BinaryPredicate >
ForwardIt unique(ForwardIt first, ForwardIt last, BinaryPredicate p);

template<class InputIt, class OutputIt >
OutputIt unique_copy(InputIt first, InputIt last,
                     OutputIt d_first);

template<class InputIt, class OutputIt, class BinaryPredicate >
OutputIt unique_copy(InputIt first, InputIt last,
                     OutputIt d_first, BinaryPredicate p);

#if CPPREFERENCE_STDVER >= 2011
template<class InputIt, class UnaryPredicate >
bool is_partitioned(InputIt first, InputIt last, UnaryPredicate p);
#endif

#if CPPREFERENCE_STDVER <2011
template<class BidirIt, class UnaryPredicate >
BidirIt partition(BidirIt first, BidirIt last, UnaryPredicate p);
#else
template<class ForwardIt, class UnaryPredicate >
ForwardIt partition(ForwardIt first, ForwardIt last, UnaryPredicate p);
#endif

#if CPPREFERENCE_STDVER >= 2011
template<class InputIt, class OutputIt1,
         class OutputIt2, class UnaryPredicate >
std::pair<OutputIt1, OutputIt2>
partition_copy(InputIt first, InputIt last,
               OutputIt1 d_first_true, OutputIt2 d_first_false,
               UnaryPredicate p);
#endif

template<class BidirIt, class UnaryPredicate >
BidirIt stable_partition(BidirIt first, BidirIt last, UnaryPredicate p);

#if CPPREFERENCE_STDVER >= 2011
template<class ForwardIt, class UnaryPredicate >
ForwardIt partition_point(ForwardIt first, ForwardIt last, UnaryPredicate p);
#endif

#if CPPREFERENCE_STDVER >= 2011
template<class ForwardIt >
bool is_sorted(ForwardIt first, ForwardIt last);

template<class ForwardIt, class Compare >
bool is_sorted(ForwardIt first, ForwardIt last, Compare comp);

template<class ForwardIt >
ForwardIt is_sorted_until(ForwardIt first, ForwardIt last);

template<class ForwardIt, class Compare >
ForwardIt is_sorted_until(ForwardIt first, ForwardIt last,
                          Compare comp);
#endif

template<class RandomIt >
void sort(RandomIt first, RandomIt last);

template<class RandomIt, class Compare >
void sort(RandomIt first, RandomIt last, Compare comp);

template<class RandomIt >
void partial_sort(RandomIt first, RandomIt middle, RandomIt last);

template<class RandomIt, class Compare >
void partial_sort(RandomIt first, RandomIt middle, RandomIt last, Compare comp);

template<class InputIt, class RandomIt >
RandomIt partial_sort_copy(InputIt first, InputIt last,
                           RandomIt d_first, RandomIt d_last);

template<class InputIt, class RandomIt, class Compare >
RandomIt partial_sort_copy(InputIt first, InputIt last,
                           RandomIt d_first, RandomIt d_last,
                           Compare comp);

template<class RandomIt >
void stable_sort(RandomIt first, RandomIt last);

template<class RandomIt, class Compare >
void stable_sort(RandomIt first, RandomIt last, Compare comp);

template<class RandomIt >
void nth_element(RandomIt first, RandomIt nth, RandomIt last);

template<class RandomIt, class Compare >
void nth_element(RandomIt first, RandomIt nth, RandomIt last, Compare comp);

template<class ForwardIt, class T >
ForwardIt lower_bound(ForwardIt first, ForwardIt last, const T& value);

template<class ForwardIt, class T, class Compare >
ForwardIt lower_bound(ForwardIt first, ForwardIt last, const T& value, Compare comp);

template<class ForwardIt, class T >
ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T& value);

template<class ForwardIt, class T, class Compare >
ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T& value, Compare comp);

template<class ForwardIt, class T >
bool binary_search(ForwardIt first, ForwardIt last, const T& value);

template<class ForwardIt, class T, class Compare >
bool binary_search(ForwardIt first, ForwardIt last, const T& value, Compare comp);

template<class ForwardIt, class T >
std::pair<ForwardIt, ForwardIt>
equal_range(ForwardIt first, ForwardIt last,
            const T& value);

template<class ForwardIt, class T, class Compare >
std::pair<ForwardIt, ForwardIt>
equal_range(ForwardIt first, ForwardIt last,
            const T& value, Compare comp);

template<class InputIt1, class InputIt2, class OutputIt >
OutputIt merge(InputIt1 first1, InputIt1 last1,
               InputIt2 first2, InputIt2 last2,
               OutputIt d_first);

template<class InputIt1, class InputIt2, class OutputIt, class Compare>
OutputIt merge(InputIt1 first1, InputIt1 last1,
               InputIt2 first2, InputIt2 last2,
               OutputIt d_first, Compare comp);

template<class BidirIt >
void inplace_merge(BidirIt first, BidirIt middle, BidirIt last);

template<class BidirIt, class Compare>
void inplace_merge(BidirIt first, BidirIt middle, BidirIt last, Compare comp);

template<class InputIt1, class InputIt2 >
bool includes(InputIt1 first1, InputIt1 last1,
              InputIt2 first2, InputIt2 last2);

template<class InputIt1, class InputIt2, class Compare >
bool includes(InputIt1 first1, InputIt1 last1,
              InputIt2 first2, InputIt2 last2, Compare comp);

template<class InputIt1, class InputIt2, class OutputIt >
OutputIt set_difference(InputIt1 first1, InputIt1 last1,
                        InputIt2 first2, InputIt2 last2,
                        OutputIt d_first);

template<class InputIt1, class InputIt2,
         class OutputIt, class Compare >
OutputIt set_difference(InputIt1 first1, InputIt1 last1,
                        InputIt2 first2, InputIt2 last2,
                        OutputIt d_first, Compare comp);

template<class InputIt1, class InputIt2, class OutputIt >
OutputIt set_intersection(InputIt1 first1, InputIt1 last1,
                          InputIt2 first2, InputIt2 last2,
                          OutputIt d_first);

template<class InputIt1, class InputIt2,
         class OutputIt, class Compare >
OutputIt set_intersection(InputIt1 first1, InputIt1 last1,
                          InputIt2 first2, InputIt2 last2,
                          OutputIt d_first, Compare comp);

template<class InputIt1, class InputIt2, class OutputIt >
OutputIt set_symmetric_difference(InputIt1 first1, InputIt1 last1,
                                  InputIt2 first2, InputIt2 last2,
                                  OutputIt d_first);

template<class InputIt1, class InputIt2,
         class OutputIt, class Compare >
OutputIt set_symmetric_difference(InputIt1 first1, InputIt1 last1,
                                  InputIt2 first2, InputIt2 last2,
                                  OutputIt d_first, Compare comp);

template<class InputIt1, class InputIt2, class OutputIt >
OutputIt set_union(InputIt1 first1, InputIt1 last1,
                   InputIt2 first2, InputIt2 last2,
                   OutputIt d_first);

template<class InputIt1, class InputIt2,
         class OutputIt, class Compare >
OutputIt set_union(InputIt1 first1, InputIt1 last1,
                   InputIt2 first2, InputIt2 last2,
                   OutputIt d_first, Compare comp);

#if CPPREFERENCE_STDVER >= 2011
template<class RandomIt >
bool is_heap(RandomIt first, RandomIt last);

template<class RandomIt, class Compare >
bool is_heap(RandomIt first, RandomIt last, Compare comp);

template<class RandomIt >
RandomIt is_heap_until(RandomIt first, RandomIt last);

template<class RandomIt, class Compare >
RandomIt is_heap_until(RandomIt first, RandomIt last, Compare comp);
#endif

template<class RandomIt >
void make_heap(RandomIt first, RandomIt last);

template<class RandomIt, class Compare >
void make_heap(RandomIt first, RandomIt last,
               Compare comp);

template<class RandomIt >
void push_heap(RandomIt first, RandomIt last);

template<class RandomIt, class Compare >
void push_heap(RandomIt first, RandomIt last,
               Compare comp);

template<class RandomIt >
void pop_heap(RandomIt first, RandomIt last);

template<class RandomIt, class Compare >
void pop_heap(RandomIt first, RandomIt last, Compare comp);

template<class RandomIt >
void sort_heap(RandomIt first, RandomIt last);

template<class RandomIt, class Compare >
void sort_heap(RandomIt first, RandomIt last, Compare comp);

#if CPPREFERENCE_STDVER <2014
template<class T >
const T& max(const T& a, const T& b);

template<class T, class Compare >
const T& max(const T& a, const T& b, Compare comp);
#else
template<class T >
constexpr const T& max(const T& a, const T& b);

template<class T, class Compare >
constexpr const T& max(const T& a, const T& b, Compare comp);
#endif

#if CPPREFERENCE_STDVER >= 2011
template<class T >
T max(std::initializer_list<T> ilist);

template<class T, class Compare >
T max(std::initializer_list<T> ilist, Compare comp);
#elif CPPREFERENCE_STDVER >= 2014
template<class T >
constexpr T max(std::initializer_list<T> ilist);

template<class T, class Compare >
constexpr T max(std::initializer_list<T> ilist, Compare comp);
#endif

#if CPPREFERENCE_STDVER <2017
template<class ForwardIt >
ForwardIt max_element(ForwardIt first, ForwardIt last);

template<class ForwardIt, class Compare >
ForwardIt max_element(ForwardIt first, ForwardIt last, Compare cmp);
#else
template<class ForwardIt >
constexpr ForwardIt max_element(ForwardIt first, ForwardIt last);

template<class ForwardIt, class Compare >
constexpr ForwardIt max_element(ForwardIt first, ForwardIt last, Compare cmp);
#endif

#if CPPREFERENCE_STDVER <2014
template<class T >
const T& min(const T& a, const T& b);

template<class T, class Compare >
const T& min(const T& a, const T& b, Compare comp);
#else
template<class T >
constexpr const T& min(const T& a, const T& b);

template<class T, class Compare >
constexpr const T& min(const T& a, const T& b, Compare comp);
#endif

#if CPPREFERENCE_STDVER >= 2011
template<class T >
T min(std::initializer_list<T> ilist);

template<class T, class Compare >
T min(std::initializer_list<T> ilist, Compare comp);
#elif CPPREFERENCE_STDVER >= 2014
template<class T >
constexpr T min(std::initializer_list<T> ilist);

template<class T, class Compare >
constexpr T min(std::initializer_list<T> ilist, Compare comp);
#endif

#if CPPREFERENCE_STDVER <2017
template<class ForwardIt >
ForwardIt min_element(ForwardIt first, ForwardIt last);

template<class ForwardIt, class Compare >
ForwardIt min_element(ForwardIt first, ForwardIt last, Compare cmp);
#else
template<class ForwardIt >
constexpr ForwardIt min_element(ForwardIt first, ForwardIt last);

template<class ForwardIt, class Compare >
constexpr ForwardIt min_element(ForwardIt first, ForwardIt last, Compare cmp);
#endif

#if CPPREFERENCE_STDVER >= 2011 && CPPREFERENCE_STDVER <2014
template<class T >
std::pair<const T&, const T&> minmax(const T& a, const T& b);

template<class T, class Compare >
std::pair<const T&, const T&> minmax(const T& a, const T& b,
                                     Compare comp);

template<class T >
std::pair<T, T> minmax(std::initializer_list<T> ilist);

template<class T, class Compare >
std::pair<T, T> minmax(std::initializer_list<T> ilist, Compare comp);

#elif CPPREFERENCE_STDVER >= 2014
template<class T >
constexpr std::pair<const T&, const T&> minmax(const T& a, const T& b);

template<class T, class Compare >
constexpr std::pair<const T&, const T&> minmax(const T& a, const T& b,
        Compare comp);
template<class T >
constexpr std::pair<T, T> minmax(std::initializer_list<T> ilist);

template<class T, class Compare >
constexpr std::pair<T, T> minmax(std::initializer_list<T> ilist, Compare comp);
#endif

#if CPPREFERENCE_STDVER >= 2011 && CPPREFERENCE_STDVER <2017
template<class ForwardIt >
std::pair<ForwardIt, ForwardIt>
minmax_element(ForwardIt first, ForwardIt last);

template<class ForwardIt, class Compare >
std::pair<ForwardIt, ForwardIt>
minmax_element(ForwardIt first, ForwardIt last, Compare comp);
#elif CPPREFERENCE_STDVER >= 2017
template<class ForwardIt >
constexpr std::pair<ForwardIt, ForwardIt>
minmax_element(ForwardIt first, ForwardIt last);

template<class ForwardIt, class Compare >
constexpr std::pair<ForwardIt, ForwardIt>
minmax_element(ForwardIt first, ForwardIt last, Compare comp);
#endif

template<class InputIt1, class InputIt2 >
bool lexicographical_compare(InputIt1 first1, InputIt1 last1,
                             InputIt2 first2, InputIt2 last2);

template<class InputIt1, class InputIt2, class Compare >
bool lexicographical_compare(InputIt1 first1, InputIt1 last1,
                             InputIt2 first2, InputIt2 last2,
                             Compare comp);

#if CPPREFERENCE_STDVER >= 2011
template<class ForwardIt1, class ForwardIt2 >
bool is_permutation(ForwardIt1 first1, ForwardIt1 last1,
                    ForwardIt2 first2);

template<class ForwardIt1, class ForwardIt2, class BinaryPredicate >
bool is_permutation(ForwardIt1 first1, ForwardIt1 last1,
                    ForwardIt2 first2, BinaryPredicate p);
#endif

#if CPPREFERENCE_STDVER >= 2011
template<class ForwardIt1, class ForwardIt2 >
bool is_permutation(ForwardIt1 first1, ForwardIt1 last1,
                    ForwardIt2 first2, ForwardIt2 last2);

template<class ForwardIt1, class ForwardIt2, class BinaryPredicate >
bool is_permutation(ForwardIt1 first1, ForwardIt1 last1,
                    ForwardIt2 first2, ForwardIt2 last2,
                    BinaryPredicate p);
#endif

template<class BidirIt >
bool next_permutation(BidirIt first, BidirIt last);

template<class BidirIt, class Compare >
bool next_permutation(BidirIt first, BidirIt last, Compare comp);

template<class BidirIt >
bool prev_permutation(BidirIt first, BidirIt last);

template<class BidirIt, class Compare >
bool prev_permutation(BidirIt first, BidirIt last, Compare comp);

} // namespace std

#endif // CPPREFERENCE_ALGORITHM_H