129 lines
7.5 KiB
Markdown
129 lines
7.5 KiB
Markdown
[alg.mismatch]
|
||
|
||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||
|
||
## 26.6 Non-modifying sequence operations [[alg.nonmodifying]](alg.nonmodifying#alg.mismatch)
|
||
|
||
### 26.6.12 Mismatch [alg.mismatch]
|
||
|
||
[ð](#lib:mismatch)
|
||
|
||
`template<class InputIterator1, class InputIterator2>
|
||
constexpr pair<InputIterator1, InputIterator2>
|
||
mismatch(InputIterator1 first1, InputIterator1 last1,
|
||
InputIterator2 first2);
|
||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
|
||
pair<ForwardIterator1, ForwardIterator2>
|
||
mismatch(ExecutionPolicy&& exec,
|
||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||
ForwardIterator2 first2);
|
||
|
||
template<class InputIterator1, class InputIterator2,
|
||
class BinaryPredicate>
|
||
constexpr pair<InputIterator1, InputIterator2>
|
||
mismatch(InputIterator1 first1, InputIterator1 last1,
|
||
InputIterator2 first2, BinaryPredicate pred);
|
||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
||
class BinaryPredicate>
|
||
pair<ForwardIterator1, ForwardIterator2>
|
||
mismatch(ExecutionPolicy&& exec,
|
||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||
ForwardIterator2 first2, BinaryPredicate pred);
|
||
|
||
template<class InputIterator1, class InputIterator2>
|
||
constexpr pair<InputIterator1, InputIterator2>
|
||
mismatch(InputIterator1 first1, InputIterator1 last1,
|
||
InputIterator2 first2, InputIterator2 last2);
|
||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
|
||
pair<ForwardIterator1, ForwardIterator2>
|
||
mismatch(ExecutionPolicy&& exec,
|
||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||
ForwardIterator2 first2, ForwardIterator2 last2);
|
||
|
||
template<class InputIterator1, class InputIterator2,
|
||
class BinaryPredicate>
|
||
constexpr pair<InputIterator1, InputIterator2>
|
||
mismatch(InputIterator1 first1, InputIterator1 last1,
|
||
InputIterator2 first2, InputIterator2 last2,
|
||
BinaryPredicate pred);
|
||
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
|
||
class BinaryPredicate>
|
||
pair<ForwardIterator1, ForwardIterator2>
|
||
mismatch(ExecutionPolicy&& exec,
|
||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||
BinaryPredicate pred);
|
||
|
||
template<[input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_iterator [iterator.concept.input]") I1, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I1> S1, [input_iterator](iterator.concept.input#concept:input_iterator "24.3.4.9 Concept input_iterator [iterator.concept.input]") I2, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I2> S2,
|
||
class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
|
||
requires [indirectly_comparable](alg.req.ind.cmp#concept:indirectly_comparable "24.3.7.5 Concept indirectly_comparable [alg.req.ind.cmp]")<I1, I2, Pred, Proj1, Proj2>
|
||
constexpr ranges::mismatch_result<I1, I2>
|
||
ranges::mismatch(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
|
||
Proj1 proj1 = {}, Proj2 proj2 = {});
|
||
template<[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R1, [input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R2,
|
||
class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
|
||
requires [indirectly_comparable](alg.req.ind.cmp#concept:indirectly_comparable "24.3.7.5 Concept indirectly_comparable [alg.req.ind.cmp]")<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
|
||
constexpr ranges::mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
|
||
ranges::mismatch(R1&& r1, R2&& r2, Pred pred = {},
|
||
Proj1 proj1 = {}, Proj2 proj2 = {});
|
||
|
||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I1, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I1> S1,
|
||
[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I2, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I2> S2,
|
||
class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
|
||
requires [indirectly_comparable](alg.req.ind.cmp#concept:indirectly_comparable "24.3.7.5 Concept indirectly_comparable [alg.req.ind.cmp]")<I1, I2, Pred, Proj1, Proj2>
|
||
ranges::mismatch_result<I1, I2>
|
||
ranges::mismatch(Ep&& exec, I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
|
||
Proj1 proj1 = {}, Proj2 proj2 = {});
|
||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R1, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R2,
|
||
class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
|
||
requires [indirectly_comparable](alg.req.ind.cmp#concept:indirectly_comparable "24.3.7.5 Concept indirectly_comparable [alg.req.ind.cmp]")<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
|
||
ranges::mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
|
||
ranges::mismatch(Ep&& exec, R1&& r1, R2&& r2, Pred pred = {},
|
||
Proj1 proj1 = {}, Proj2 proj2 = {});
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L5543)
|
||
|
||
Let last2 be first2 + (last1 - first1) for the overloads in namespace std with no parameter last2[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L5547)
|
||
|
||
Let E be:
|
||
|
||
- [(2.1)](#2.1)
|
||
|
||
!(*(first1 + n) == *(first2 + n)) for the overloads with no parameter pred;
|
||
|
||
- [(2.2)](#2.2)
|
||
|
||
pred(*(first1 + n), *(first2 + n)) == false for the overloads with a parameter pred and
|
||
no parameter proj1;
|
||
|
||
- [(2.3)](#2.3)
|
||
|
||
!invoke(pred, invoke(proj1, *(first1 + n)), invoke(proj2, *(first2 + n))) for the overloads with both parameters pred and proj1[.](#2.sentence-1)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L5563)
|
||
|
||
Let N be min(last1 - first1, last2 - first2)[.](#3.sentence-1)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L5566)
|
||
|
||
*Returns*: { first1 + n, first2 + n },
|
||
where n is the smallest integer in [0, N) such that E holds,
|
||
or N if no such integer exists[.](#4.sentence-1)
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L5572)
|
||
|
||
*Complexity*: At most N applications of the corresponding predicate and any projections[.](#5.sentence-1)
|