tmp/tmpw8576ayy/{from.md → to.md}
RENAMED
|
@@ -5,15 +5,15 @@ a function object of type `Compare` and one that uses an `operator<`.
|
|
| 5 |
|
| 6 |
`Compare`
|
| 7 |
|
| 8 |
is a function object type ([[function.objects]]). The return value of
|
| 9 |
the function call operation applied to an object of type `Compare`, when
|
| 10 |
-
contextually converted to `bool`
|
| 11 |
-
argument of the call is less than the second, and `false`
|
| 12 |
-
`Compare comp` is used throughout for algorithms assuming an
|
| 13 |
-
relation. It is assumed that `comp` will not apply any
|
| 14 |
-
function through the dereferenced iterator.
|
| 15 |
|
| 16 |
For all algorithms that take `Compare`, there is a version that uses
|
| 17 |
`operator<` instead. That is, `comp(*i, *j) != false` defaults to
|
| 18 |
`*i < *j != false`. For algorithms other than those described in
|
| 19 |
[[alg.binary.search]] to work correctly, `comp` has to induce a strict
|
|
@@ -32,12 +32,12 @@ for a partial ordering. If we define `equiv(a, b)` as
|
|
| 32 |
- `equiv` is an equivalence relation
|
| 33 |
- `comp` induces a well-defined relation on the equivalence classes
|
| 34 |
determined by `equiv`
|
| 35 |
- The induced relation is a strict total ordering.
|
| 36 |
|
| 37 |
-
A sequence is *sorted with respect to a comparator* `comp` if for
|
| 38 |
-
iterator `i` pointing to the sequence and
|
| 39 |
such that `i + n` is a valid iterator pointing to an element of the
|
| 40 |
sequence, `comp(*(i + n), *i) == false`.
|
| 41 |
|
| 42 |
A sequence \[`start`, `finish`) is *partitioned with respect to an
|
| 43 |
expression* `f(e)` if there exists an integer `n` such that for all
|
|
@@ -94,11 +94,11 @@ shall satisfy the requirements of `MoveConstructible`
|
|
| 94 |
(Table [[moveassignable]]).
|
| 95 |
|
| 96 |
*Complexity:* It does at most N log²(N) (where N` == last - first`)
|
| 97 |
comparisons; if enough extra memory is available, it is N log(N).
|
| 98 |
|
| 99 |
-
*Remarks:* Stable.
|
| 100 |
|
| 101 |
#### `partial_sort` <a id="partial.sort">[[partial.sort]]</a>
|
| 102 |
|
| 103 |
``` cpp
|
| 104 |
template<class RandomAccessIterator>
|
|
@@ -206,13 +206,13 @@ template<class RandomAccessIterator, class Compare>
|
|
| 206 |
RandomAccessIterator last, Compare comp);
|
| 207 |
```
|
| 208 |
|
| 209 |
After `nth_element` the element in the position pointed to by `nth` is
|
| 210 |
the element that would be in that position if the whole range were
|
| 211 |
-
sorted. Also for
|
| 212 |
-
iterator `j` in the range \[`nth`, `last`)
|
| 213 |
-
or `comp(*j, *i) == false`.
|
| 214 |
|
| 215 |
*Requires:* `RandomAccessIterator` shall satisfy the requirements of
|
| 216 |
`ValueSwappable` ([[swappable.requirements]]). The type of `*first`
|
| 217 |
shall satisfy the requirements of `MoveConstructible`
|
| 218 |
(Table [[moveconstructible]]) and of `MoveAssignable`
|
|
@@ -248,15 +248,15 @@ template<class ForwardIterator, class T, class Compare>
|
|
| 248 |
|
| 249 |
*Requires:* The elements `e` of \[`first`, `last`) shall be partitioned
|
| 250 |
with respect to the expression `e < value` or `comp(e, value)`.
|
| 251 |
|
| 252 |
*Returns:* The furthermost iterator `i` in the range \[`first`, `last`\]
|
| 253 |
-
such that for
|
| 254 |
following corresponding conditions hold: `*j < value` or
|
| 255 |
`comp(*j, value) != false`.
|
| 256 |
|
| 257 |
-
*Complexity:* At most log₂(last - first) + 𝑂(1) comparisons.
|
| 258 |
|
| 259 |
#### `upper_bound` <a id="upper.bound">[[upper.bound]]</a>
|
| 260 |
|
| 261 |
``` cpp
|
| 262 |
template<class ForwardIterator, class T>
|
|
@@ -272,15 +272,15 @@ template<class ForwardIterator, class T, class Compare>
|
|
| 272 |
|
| 273 |
*Requires:* The elements `e` of \[`first`, `last`) shall be partitioned
|
| 274 |
with respect to the expression `!(value < e)` or `!comp(value, e)`.
|
| 275 |
|
| 276 |
*Returns:* The furthermost iterator `i` in the range \[`first`, `last`\]
|
| 277 |
-
such that for
|
| 278 |
following corresponding conditions hold: `!(value < *j)` or
|
| 279 |
`comp(value, *j) == false`.
|
| 280 |
|
| 281 |
-
*Complexity:* At most log₂(last - first) + 𝑂(1) comparisons.
|
| 282 |
|
| 283 |
#### `equal_range` <a id="equal.range">[[equal.range]]</a>
|
| 284 |
|
| 285 |
``` cpp
|
| 286 |
template<class ForwardIterator, class T>
|
|
@@ -313,11 +313,11 @@ or
|
|
| 313 |
``` cpp
|
| 314 |
make_pair(lower_bound(first, last, value, comp),
|
| 315 |
upper_bound(first, last, value, comp))
|
| 316 |
```
|
| 317 |
|
| 318 |
-
*Complexity:* At most 2 * log₂(last - first) + 𝑂(1) comparisons.
|
| 319 |
|
| 320 |
#### `binary_search` <a id="binary.search">[[binary.search]]</a>
|
| 321 |
|
| 322 |
``` cpp
|
| 323 |
template<class ForwardIterator, class T>
|
|
@@ -338,11 +338,11 @@ implies `!comp(value, e)`.
|
|
| 338 |
*Returns:* `true` if there is an iterator `i` in the range \[`first`,
|
| 339 |
`last`) that satisfies the corresponding conditions:
|
| 340 |
`!(*i < value) && !(value < *i)` or
|
| 341 |
`comp(*i, value) == false && comp(value, *i) == false`.
|
| 342 |
|
| 343 |
-
*Complexity:* At most
|
| 344 |
|
| 345 |
### Merge <a id="alg.merge">[[alg.merge]]</a>
|
| 346 |
|
| 347 |
``` cpp
|
| 348 |
template<class InputIterator1, class InputIterator2,
|
|
@@ -374,11 +374,11 @@ range shall not overlap with either of the original ranges.
|
|
| 374 |
*Returns:* `result + (last1 - first1) + (last2 - first2)`.
|
| 375 |
|
| 376 |
*Complexity:* At most `(last1 - first1) + (last2 - first2) - 1`
|
| 377 |
comparisons.
|
| 378 |
|
| 379 |
-
*Remarks:* Stable.
|
| 380 |
|
| 381 |
``` cpp
|
| 382 |
template<class BidirectionalIterator>
|
| 383 |
void inplace_merge(BidirectionalIterator first,
|
| 384 |
BidirectionalIterator middle,
|
|
@@ -408,11 +408,11 @@ shall satisfy the requirements of `MoveConstructible`
|
|
| 408 |
*Complexity:* When enough additional memory is available,
|
| 409 |
`(last - first) - 1` comparisons. If no additional memory is available,
|
| 410 |
an algorithm with complexity N log(N) (where `N` is equal to
|
| 411 |
`last - first`) may be used.
|
| 412 |
|
| 413 |
-
*Remarks:* Stable.
|
| 414 |
|
| 415 |
### Set operations on sorted structures <a id="alg.set.operations">[[alg.set.operations]]</a>
|
| 416 |
|
| 417 |
This section defines all the basic set operations on sorted structures.
|
| 418 |
They also work with `multiset`s ([[multiset]]) containing multiple
|
|
@@ -728,13 +728,13 @@ returns the last iterator `i` in \[`first`, `last`\] for which the range
|
|
| 728 |
*Complexity:* Linear.
|
| 729 |
|
| 730 |
### Minimum and maximum <a id="alg.min.max">[[alg.min.max]]</a>
|
| 731 |
|
| 732 |
``` cpp
|
| 733 |
-
template<class T> const T& min(const T& a, const T& b);
|
| 734 |
template<class T, class Compare>
|
| 735 |
-
const T& min(const T& a, const T& b, Compare comp);
|
| 736 |
```
|
| 737 |
|
| 738 |
*Requires:* Type `T` is `LessThanComparable`
|
| 739 |
(Table [[lessthancomparable]]).
|
| 740 |
|
|
@@ -742,13 +742,13 @@ template<class T, class Compare>
|
|
| 742 |
|
| 743 |
*Remarks:* Returns the first argument when the arguments are equivalent.
|
| 744 |
|
| 745 |
``` cpp
|
| 746 |
template<class T>
|
| 747 |
-
T min(initializer_list<T> t);
|
| 748 |
template<class T, class Compare>
|
| 749 |
-
T min(initializer_list<T> t, Compare comp);
|
| 750 |
```
|
| 751 |
|
| 752 |
*Requires:* `T` is `LessThanComparable` and `CopyConstructible` and
|
| 753 |
`t.size() > 0`.
|
| 754 |
|
|
@@ -756,13 +756,13 @@ template<class T, class Compare>
|
|
| 756 |
|
| 757 |
*Remarks:* Returns a copy of the leftmost argument when several
|
| 758 |
arguments are equivalent to the smallest.
|
| 759 |
|
| 760 |
``` cpp
|
| 761 |
-
template<class T> const T& max(const T& a, const T& b);
|
| 762 |
template<class T, class Compare>
|
| 763 |
-
const T& max(const T& a, const T& b, Compare comp);
|
| 764 |
```
|
| 765 |
|
| 766 |
*Requires:* Type `T` is `LessThanComparable`
|
| 767 |
(Table [[lessthancomparable]]).
|
| 768 |
|
|
@@ -770,13 +770,13 @@ template<class T, class Compare>
|
|
| 770 |
|
| 771 |
*Remarks:* Returns the first argument when the arguments are equivalent.
|
| 772 |
|
| 773 |
``` cpp
|
| 774 |
template<class T>
|
| 775 |
-
T max(initializer_list<T> t);
|
| 776 |
template<class T, class Compare>
|
| 777 |
-
T max(initializer_list<T> t, Compare comp);
|
| 778 |
```
|
| 779 |
|
| 780 |
*Requires:* `T` is `LessThanComparable` and `CopyConstructible` and
|
| 781 |
`t.size() > 0`.
|
| 782 |
|
|
@@ -784,13 +784,13 @@ template<class T, class Compare>
|
|
| 784 |
|
| 785 |
*Remarks:* Returns a copy of the leftmost argument when several
|
| 786 |
arguments are equivalent to the largest.
|
| 787 |
|
| 788 |
``` cpp
|
| 789 |
-
template<class T> pair<const T&, const T&> minmax(const T& a, const T& b);
|
| 790 |
template<class T, class Compare>
|
| 791 |
-
pair<const T&, const T&> minmax(const T& a, const T& b, Compare comp);
|
| 792 |
```
|
| 793 |
|
| 794 |
*Requires:* Type `T` shall be `LessThanComparable`
|
| 795 |
(Table [[lessthancomparable]]).
|
| 796 |
|
|
@@ -802,13 +802,13 @@ are equivalent.
|
|
| 802 |
|
| 803 |
*Complexity:* Exactly one comparison.
|
| 804 |
|
| 805 |
``` cpp
|
| 806 |
template<class T>
|
| 807 |
-
pair<T, T> minmax(initializer_list<T> t);
|
| 808 |
template<class T, class Compare>
|
| 809 |
-
pair<T, T> minmax(initializer_list<T> t, Compare comp);
|
| 810 |
```
|
| 811 |
|
| 812 |
*Requires:* `T` is `LessThanComparable` and `CopyConstructible` and
|
| 813 |
`t.size() > 0`.
|
| 814 |
|
|
@@ -830,13 +830,13 @@ template<class ForwardIterator, class Compare>
|
|
| 830 |
ForwardIterator min_element(ForwardIterator first, ForwardIterator last,
|
| 831 |
Compare comp);
|
| 832 |
```
|
| 833 |
|
| 834 |
*Returns:* The first iterator `i` in the range \[`first`, `last`) such
|
| 835 |
-
that for
|
| 836 |
-
corresponding conditions hold: `!(*j < *i)` or
|
| 837 |
-
Returns `last` if `first == last`.
|
| 838 |
|
| 839 |
*Complexity:* Exactly `max((last - first) - 1, 0)` applications of the
|
| 840 |
corresponding comparisons.
|
| 841 |
|
| 842 |
``` cpp
|
|
@@ -846,13 +846,13 @@ template<class ForwardIterator, class Compare>
|
|
| 846 |
ForwardIterator max_element(ForwardIterator first, ForwardIterator last,
|
| 847 |
Compare comp);
|
| 848 |
```
|
| 849 |
|
| 850 |
*Returns:* The first iterator `i` in the range \[`first`, `last`) such
|
| 851 |
-
that for
|
| 852 |
-
corresponding conditions hold: `!(*i < *j)` or
|
| 853 |
-
Returns `last` if `first == last`.
|
| 854 |
|
| 855 |
*Complexity:* Exactly `max((last - first) - 1, 0)` applications of the
|
| 856 |
corresponding comparisons.
|
| 857 |
|
| 858 |
``` cpp
|
|
|
|
| 5 |
|
| 6 |
`Compare`
|
| 7 |
|
| 8 |
is a function object type ([[function.objects]]). The return value of
|
| 9 |
the function call operation applied to an object of type `Compare`, when
|
| 10 |
+
contextually converted to `bool` (Clause [[conv]]), yields `true` if
|
| 11 |
+
the first argument of the call is less than the second, and `false`
|
| 12 |
+
otherwise. `Compare comp` is used throughout for algorithms assuming an
|
| 13 |
+
ordering relation. It is assumed that `comp` will not apply any
|
| 14 |
+
non-constant function through the dereferenced iterator.
|
| 15 |
|
| 16 |
For all algorithms that take `Compare`, there is a version that uses
|
| 17 |
`operator<` instead. That is, `comp(*i, *j) != false` defaults to
|
| 18 |
`*i < *j != false`. For algorithms other than those described in
|
| 19 |
[[alg.binary.search]] to work correctly, `comp` has to induce a strict
|
|
|
|
| 32 |
- `equiv` is an equivalence relation
|
| 33 |
- `comp` induces a well-defined relation on the equivalence classes
|
| 34 |
determined by `equiv`
|
| 35 |
- The induced relation is a strict total ordering.
|
| 36 |
|
| 37 |
+
A sequence is *sorted with respect to a comparator* `comp` if for every
|
| 38 |
+
iterator `i` pointing to the sequence and every non-negative integer `n`
|
| 39 |
such that `i + n` is a valid iterator pointing to an element of the
|
| 40 |
sequence, `comp(*(i + n), *i) == false`.
|
| 41 |
|
| 42 |
A sequence \[`start`, `finish`) is *partitioned with respect to an
|
| 43 |
expression* `f(e)` if there exists an integer `n` such that for all
|
|
|
|
| 94 |
(Table [[moveassignable]]).
|
| 95 |
|
| 96 |
*Complexity:* It does at most N log²(N) (where N` == last - first`)
|
| 97 |
comparisons; if enough extra memory is available, it is N log(N).
|
| 98 |
|
| 99 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 100 |
|
| 101 |
#### `partial_sort` <a id="partial.sort">[[partial.sort]]</a>
|
| 102 |
|
| 103 |
``` cpp
|
| 104 |
template<class RandomAccessIterator>
|
|
|
|
| 206 |
RandomAccessIterator last, Compare comp);
|
| 207 |
```
|
| 208 |
|
| 209 |
After `nth_element` the element in the position pointed to by `nth` is
|
| 210 |
the element that would be in that position if the whole range were
|
| 211 |
+
sorted, unless `nth == last`. Also for every iterator `i` in the range
|
| 212 |
+
\[`first`, `nth`) and every iterator `j` in the range \[`nth`, `last`)
|
| 213 |
+
it holds that: `!(*j < *i)` or `comp(*j, *i) == false`.
|
| 214 |
|
| 215 |
*Requires:* `RandomAccessIterator` shall satisfy the requirements of
|
| 216 |
`ValueSwappable` ([[swappable.requirements]]). The type of `*first`
|
| 217 |
shall satisfy the requirements of `MoveConstructible`
|
| 218 |
(Table [[moveconstructible]]) and of `MoveAssignable`
|
|
|
|
| 248 |
|
| 249 |
*Requires:* The elements `e` of \[`first`, `last`) shall be partitioned
|
| 250 |
with respect to the expression `e < value` or `comp(e, value)`.
|
| 251 |
|
| 252 |
*Returns:* The furthermost iterator `i` in the range \[`first`, `last`\]
|
| 253 |
+
such that for every iterator `j` in the range \[`first`, `i`) the
|
| 254 |
following corresponding conditions hold: `*j < value` or
|
| 255 |
`comp(*j, value) != false`.
|
| 256 |
|
| 257 |
+
*Complexity:* At most log₂(`last - first`) + 𝑂(1) comparisons.
|
| 258 |
|
| 259 |
#### `upper_bound` <a id="upper.bound">[[upper.bound]]</a>
|
| 260 |
|
| 261 |
``` cpp
|
| 262 |
template<class ForwardIterator, class T>
|
|
|
|
| 272 |
|
| 273 |
*Requires:* The elements `e` of \[`first`, `last`) shall be partitioned
|
| 274 |
with respect to the expression `!(value < e)` or `!comp(value, e)`.
|
| 275 |
|
| 276 |
*Returns:* The furthermost iterator `i` in the range \[`first`, `last`\]
|
| 277 |
+
such that for every iterator `j` in the range \[`first`, `i`) the
|
| 278 |
following corresponding conditions hold: `!(value < *j)` or
|
| 279 |
`comp(value, *j) == false`.
|
| 280 |
|
| 281 |
+
*Complexity:* At most log₂(`last - first`) + 𝑂(1) comparisons.
|
| 282 |
|
| 283 |
#### `equal_range` <a id="equal.range">[[equal.range]]</a>
|
| 284 |
|
| 285 |
``` cpp
|
| 286 |
template<class ForwardIterator, class T>
|
|
|
|
| 313 |
``` cpp
|
| 314 |
make_pair(lower_bound(first, last, value, comp),
|
| 315 |
upper_bound(first, last, value, comp))
|
| 316 |
```
|
| 317 |
|
| 318 |
+
*Complexity:* At most 2 * log₂(`last - first`) + 𝑂(1) comparisons.
|
| 319 |
|
| 320 |
#### `binary_search` <a id="binary.search">[[binary.search]]</a>
|
| 321 |
|
| 322 |
``` cpp
|
| 323 |
template<class ForwardIterator, class T>
|
|
|
|
| 338 |
*Returns:* `true` if there is an iterator `i` in the range \[`first`,
|
| 339 |
`last`) that satisfies the corresponding conditions:
|
| 340 |
`!(*i < value) && !(value < *i)` or
|
| 341 |
`comp(*i, value) == false && comp(value, *i) == false`.
|
| 342 |
|
| 343 |
+
*Complexity:* At most log₂(`last - first`) + 𝑂(1) comparisons.
|
| 344 |
|
| 345 |
### Merge <a id="alg.merge">[[alg.merge]]</a>
|
| 346 |
|
| 347 |
``` cpp
|
| 348 |
template<class InputIterator1, class InputIterator2,
|
|
|
|
| 374 |
*Returns:* `result + (last1 - first1) + (last2 - first2)`.
|
| 375 |
|
| 376 |
*Complexity:* At most `(last1 - first1) + (last2 - first2) - 1`
|
| 377 |
comparisons.
|
| 378 |
|
| 379 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 380 |
|
| 381 |
``` cpp
|
| 382 |
template<class BidirectionalIterator>
|
| 383 |
void inplace_merge(BidirectionalIterator first,
|
| 384 |
BidirectionalIterator middle,
|
|
|
|
| 408 |
*Complexity:* When enough additional memory is available,
|
| 409 |
`(last - first) - 1` comparisons. If no additional memory is available,
|
| 410 |
an algorithm with complexity N log(N) (where `N` is equal to
|
| 411 |
`last - first`) may be used.
|
| 412 |
|
| 413 |
+
*Remarks:* Stable ([[algorithm.stable]]).
|
| 414 |
|
| 415 |
### Set operations on sorted structures <a id="alg.set.operations">[[alg.set.operations]]</a>
|
| 416 |
|
| 417 |
This section defines all the basic set operations on sorted structures.
|
| 418 |
They also work with `multiset`s ([[multiset]]) containing multiple
|
|
|
|
| 728 |
*Complexity:* Linear.
|
| 729 |
|
| 730 |
### Minimum and maximum <a id="alg.min.max">[[alg.min.max]]</a>
|
| 731 |
|
| 732 |
``` cpp
|
| 733 |
+
template<class T> constexpr const T& min(const T& a, const T& b);
|
| 734 |
template<class T, class Compare>
|
| 735 |
+
constexpr const T& min(const T& a, const T& b, Compare comp);
|
| 736 |
```
|
| 737 |
|
| 738 |
*Requires:* Type `T` is `LessThanComparable`
|
| 739 |
(Table [[lessthancomparable]]).
|
| 740 |
|
|
|
|
| 742 |
|
| 743 |
*Remarks:* Returns the first argument when the arguments are equivalent.
|
| 744 |
|
| 745 |
``` cpp
|
| 746 |
template<class T>
|
| 747 |
+
constexpr T min(initializer_list<T> t);
|
| 748 |
template<class T, class Compare>
|
| 749 |
+
constexpr T min(initializer_list<T> t, Compare comp);
|
| 750 |
```
|
| 751 |
|
| 752 |
*Requires:* `T` is `LessThanComparable` and `CopyConstructible` and
|
| 753 |
`t.size() > 0`.
|
| 754 |
|
|
|
|
| 756 |
|
| 757 |
*Remarks:* Returns a copy of the leftmost argument when several
|
| 758 |
arguments are equivalent to the smallest.
|
| 759 |
|
| 760 |
``` cpp
|
| 761 |
+
template<class T> constexpr const T& max(const T& a, const T& b);
|
| 762 |
template<class T, class Compare>
|
| 763 |
+
constexpr const T& max(const T& a, const T& b, Compare comp);
|
| 764 |
```
|
| 765 |
|
| 766 |
*Requires:* Type `T` is `LessThanComparable`
|
| 767 |
(Table [[lessthancomparable]]).
|
| 768 |
|
|
|
|
| 770 |
|
| 771 |
*Remarks:* Returns the first argument when the arguments are equivalent.
|
| 772 |
|
| 773 |
``` cpp
|
| 774 |
template<class T>
|
| 775 |
+
constexpr T max(initializer_list<T> t);
|
| 776 |
template<class T, class Compare>
|
| 777 |
+
constexpr T max(initializer_list<T> t, Compare comp);
|
| 778 |
```
|
| 779 |
|
| 780 |
*Requires:* `T` is `LessThanComparable` and `CopyConstructible` and
|
| 781 |
`t.size() > 0`.
|
| 782 |
|
|
|
|
| 784 |
|
| 785 |
*Remarks:* Returns a copy of the leftmost argument when several
|
| 786 |
arguments are equivalent to the largest.
|
| 787 |
|
| 788 |
``` cpp
|
| 789 |
+
template<class T> constexpr pair<const T&, const T&> minmax(const T& a, const T& b);
|
| 790 |
template<class T, class Compare>
|
| 791 |
+
constexpr pair<const T&, const T&> minmax(const T& a, const T& b, Compare comp);
|
| 792 |
```
|
| 793 |
|
| 794 |
*Requires:* Type `T` shall be `LessThanComparable`
|
| 795 |
(Table [[lessthancomparable]]).
|
| 796 |
|
|
|
|
| 802 |
|
| 803 |
*Complexity:* Exactly one comparison.
|
| 804 |
|
| 805 |
``` cpp
|
| 806 |
template<class T>
|
| 807 |
+
constexpr pair<T, T> minmax(initializer_list<T> t);
|
| 808 |
template<class T, class Compare>
|
| 809 |
+
constexpr pair<T, T> minmax(initializer_list<T> t, Compare comp);
|
| 810 |
```
|
| 811 |
|
| 812 |
*Requires:* `T` is `LessThanComparable` and `CopyConstructible` and
|
| 813 |
`t.size() > 0`.
|
| 814 |
|
|
|
|
| 830 |
ForwardIterator min_element(ForwardIterator first, ForwardIterator last,
|
| 831 |
Compare comp);
|
| 832 |
```
|
| 833 |
|
| 834 |
*Returns:* The first iterator `i` in the range \[`first`, `last`) such
|
| 835 |
+
that for every iterator `j` in the range \[`first`, `last`) the
|
| 836 |
+
following corresponding conditions hold: `!(*j < *i)` or
|
| 837 |
+
`comp(*j, *i) == false`. Returns `last` if `first == last`.
|
| 838 |
|
| 839 |
*Complexity:* Exactly `max((last - first) - 1, 0)` applications of the
|
| 840 |
corresponding comparisons.
|
| 841 |
|
| 842 |
``` cpp
|
|
|
|
| 846 |
ForwardIterator max_element(ForwardIterator first, ForwardIterator last,
|
| 847 |
Compare comp);
|
| 848 |
```
|
| 849 |
|
| 850 |
*Returns:* The first iterator `i` in the range \[`first`, `last`) such
|
| 851 |
+
that for every iterator `j` in the range \[`first`, `last`) the
|
| 852 |
+
following corresponding conditions hold: `!(*i < *j)` or
|
| 853 |
+
`comp(*i, *j) == false`. Returns `last` if `first == last`.
|
| 854 |
|
| 855 |
*Complexity:* Exactly `max((last - first) - 1, 0)` applications of the
|
| 856 |
corresponding comparisons.
|
| 857 |
|
| 858 |
``` cpp
|