Namespaces
Variants

std::experimental::ranges:: mismatch

From cppreference.net
**注記**: このコードはC++のテンプレート宣言であり、HTMLタグ内のコード部分は翻訳対象外としました。C++のキーワード、型名、関数名などの専門用語は原文のまま保持しています。 (注:このHTML要素には翻訳対象のテキストコンテンツが含まれていないため、元の構造をそのまま保持しています)
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 ) > ;
(1) (ranges TS)
template < InputRange R1, InputRange R2,

class Proj1 = ranges:: identity , class Proj2 = ranges:: identity ,
class Pred = ranges:: equal_to <> >
requires IndirectRelation < Pred, projected < ranges:: iterator_t < R1 > , Proj1 > ,
projected < ranges:: iterator_t < R2 > , Proj2 >>
auto mismatch ( R1 && r1, R2 && r2, Pred pred = Pred { } ,
Proj1 proj1 = Proj1 { } , Proj2 proj2 = Proj2 { } )
- > ranges:: tagged_pair < tag:: in1 ( ranges:: safe_iterator_t < R1 > ) ,

tag:: in2 ( ranges:: safe_iterator_t < R2 > ) > ;
(2) (ranges TS)
template < InputIterator I1, Sentinel < I1 > S1, class I2,

class Pred = ranges:: equal_to <> ,
class Proj1 = ranges:: identity , class Proj2 = ranges:: identity >
requires InputIterator < std:: decay_t < I2 >> && ! Range < I2 > &&
IndirectRelation < Pred, projected < I1, Proj1 > ,
projected < std:: decay_t < I2 > , Proj2 >>
auto mismatch ( I1 first1, S1 last1, I2 && first2_, Pred pred = Pred { } ,
Proj1 proj1 = Proj1 { } , Proj2 proj2 = Proj2 { } )

- > ranges:: tagged_pair < tag:: in1 ( I1 ) , tag:: in2 ( std:: decay_t < I2 > ) > ;
(3) (ranges TS)
(非推奨)
template < InputRange R1, class I2, class Pred = ranges:: equal_to <> ,

class Proj1 = ranges:: identity , class Proj2 = ranges:: identity >
requires InputIterator < std:: decay_t < I2 >> && ! Range < I2 > &&
IndirectRelation < Pred, projected < ranges:: iterator_t < R1 > , Proj1 > ,
projected < std:: decay_t < I2 > , Proj2 >>
auto mismatch ( R1 && r1, I2 && first2_, Pred pred = Pred { } ,
Proj1 proj1 = Proj1 { } , Proj2 proj2 = Proj2 { } )
- > ranges:: tagged_pair < tag:: in1 ( ranges:: safe_iterator_t < Rng1 > ) ,

tag:: in2 ( std:: decay_t < I2 > ) > ;
(4) (ranges TS)
(非推奨)
1) 2つの範囲から最初に不一致となる要素のペアを返します:1つは [ first1 , last1 ) で定義され、もう1つは [ first2 , last2 ) で定義されます。
2) (1) と同様だが、 r1 を第一ソース範囲として、 r2 を第二ソース範囲として使用する。すなわち、 ranges:: begin ( r1 ) first1 として、 ranges:: end ( r1 ) last1 として、 ranges:: begin ( r2 ) first2 として、 ranges:: end ( r2 ) last2 として使用する場合と同等である。
3) (1) と同様だが、 first2 std:: decay_t < I2 > first2 = std:: forward < I2 > ( first2_ ) ; であり、 last2 ranges :: unreachable { であるかのように動作する。基盤となるアルゴリズムは first2 last1 - first1 回を超えてインクリメントすることはない。
4) (3) と同様だが、 r1 を最初のソース範囲として使用する。 ranges:: begin ( r1 ) first1 として、 ranges:: end ( r1 ) last1 として使用するかのように動作する。

要素は、2つの範囲の射影された要素に対して pred を使用して比較されます。比較は以下のように行われます: ranges:: invoke ( pred, ranges:: invoke ( proj1, * i ) , ranges:: invoke ( proj2, * j ) )

上記に示された宣言にかかわらず、アルゴリズム宣言の実際のテンプレートパラメータの数と順序は未規定です。したがって、アルゴリズムを呼び出す際に明示的なテンプレート引数を使用する場合、プログラムはおそらく移植性がありません。

目次

翻訳のポイント: - 「Contents」→「目次」に翻訳 - HTMLタグ、属性、
タグ内のテキストは翻訳せず保持
- C++関連の専門用語(Parameters、Return value、Complexity、Possible implementation、Example、See also)は原文のまま保持
- 数値、クラス名、IDなどは変更せず
- フォーマットと構造は完全に保持

パラメータ

first1, last1 - 要素の最初の範囲
r1 - 要素の最初の範囲
first2, last2 - 要素の2番目の範囲
r2 - 要素の2番目の範囲
first2_ - 要素の2番目の範囲の開始位置
pred - 投影された要素に適用する述語
proj1 - 最初の範囲の要素に適用する投影
proj2 - 2番目の範囲の要素に適用する投影

戻り値

最初の2つの等しくない要素へのイテレータを持つ tagged_pair オブジェクト(最初の範囲からのイテレータはタグ in1 を持ち、2番目の範囲からのイテレータはタグ in2 を持つ)。

比較が last1 または last2 に到達した時点で不一致が見つからない場合、そのペアは終端イテレータと他方の範囲からの対応するイテレータを保持します。

計算量

最大で last1 - first1 回の述語と各射影の適用。

実装例

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};
}

関連項目

2つの範囲が最初に異なる位置を見つける
(関数テンプレート)
2つの要素集合が同じかどうかを判定する
(関数テンプレート)
特定の基準を満たす最初の要素を見つける
(関数テンプレート)
一方の範囲が辞書順でもう一方より小さい場合 true を返す
(関数テンプレート)
要素の範囲を検索する
(関数テンプレート)