std::experimental::ranges::mismatch
Defined in header <experimental/ranges/algorithm>
|
||
template< InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2, class Proj1 = ranges::identity, class Proj2 = ranges::identity, |
(1) | (ranges TS) |
template< InputRange R1, InputRange R2, class Proj1 = ranges::identity, class Proj2 = ranges::identity, |
(2) | (ranges TS) |
template< InputIterator I1, Sentinel<I1> S1, class I2, class Pred = ranges::equal_to<>, |
(3) | (ranges TS) (deprecated) |
template< InputRange R1, class I2, class Pred = ranges::equal_to<>, class Proj1 = ranges::identity, class Proj2 = ranges::identity > |
(4) | (ranges TS) (deprecated) |
[
first1,
last1)
and another defined by [
first2,
last2)
.Elements are compared using pred to the projected elements of the two ranges, as if by ranges::invoke(pred, ranges::invoke(proj1, *i), ranges::invoke(proj2, *j)).
Notwithstanding the declarations depicted above, the actual number and order of template parameters for algorithm declarations is unspecified. Thus, if explicit template arguments are used when calling an algorithm, the program is probably non-portable.
Parameters
first1, last1 | - | the first range of the elements |
r1 | - | the first range of the elements |
first2, last2 | - | the second range of the elements |
r2 | - | the second range of the elements |
first2_ | - | the beginning of the second range of the elements |
pred | - | predicate to apply to the projected elements |
proj1 | - | projection to apply to the elements in the first range |
proj2 | - | projection to apply to the elements in the second range |
Return value
A tagged_pair
object with iterators to the first two non-equal elements (the iterator from the first range has the tag in1 and the iterator from the second range has the tag in2).
If no mismatches are found when the comparison reaches last1 or last2, whichever happens first, the pair holds the end iterator and the corresponding iterator from the other range.
Complexity
At most last1 - first1 applications of the predicate and each projection.
Possible implementation
template<InputIterator I1, Sentinel<I1> S1, InputIterator I2, Sentinel<I2> S2, class Proj1 = ranges::identity, class Proj2 = ranges::identity, class Pred = ranges::equal_to<>> requires IndirectRelation<Pred, projected<I1, Proj1>, projected<I2, Proj2>> auto mismatch(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = Pred{}, Proj1 proj1 = Proj1{}, Proj2 proj2 = Proj2{}) -> ranges::tagged_pair<tag::in1(I1), tag::in2(I2)> { while (first1 != last1 && first2 != last2 && ranges::invoke(pred, ranges::invoke(proj1, *first1), ranges::invoke(proj2, *first2))) { ++first1; ++first2; } return {first1, first2}; } |
Example
This section is incomplete Reason: no example |
See also
finds the first position where two ranges differ (function template) | |
determines if two sets of elements are the same (function template) | |
finds the first element satisfying specific criteria (function template) | |
returns true if one range is lexicographically less than another (function template) | |
searches for a range of elements (function template) |