名前空間
変種
操作

std::lexicographical_compare_three_way

提供: cppreference.com
< cpp‎ | algorithm
 
 
アルゴリズムライブラリ
制約付きアルゴリズムと範囲に対するアルゴリズム (C++20)
コンセプトとユーティリティ: std::sortable, std::projected, ...
制約付きアルゴリズム: std::ranges::copy, std::ranges::sort, ...
実行ポリシー (C++17)
非変更シーケンス操作
(C++11)(C++11)(C++11)
(C++17)
lexicographical_compare_three_way
(C++20)

変更シーケンス操作
未初期化記憶域の操作
分割操作
ソート操作
(C++11)
二分探索操作
集合操作 (ソート済み範囲用)
ヒープ操作
(C++11)
最小/最大演算
(C++11)
(C++17)

順列
数値演算
C のライブラリ
 
ヘッダ <algorithm> で定義
template< class InputIt1, class InputIt2, class Cmp >

constexpr auto lexicographical_compare_three_way( InputIt1 first1, InputIt1 last1,
                                                  InputIt2 first2, InputIt2 last2,
                                                  Cmp comp)

-> decltype(comp(*first1, *first2));
(1) (C++20以上)
template< class InputIt1, class InputIt2 >

constexpr auto lexicographical_compare_three_way( InputIt1 first1, InputIt1 last1,

                                                  InputIt2 first2, InputIt2 last2);
(2) (C++20以上)

三方比較を用いて2つの範囲 [first1, last1)[first2, last2) を辞書的に比較し、適用可能な最も強い比較カテゴリ型の結果を生成します。

1) 以下のように定義されているかのように動作します。
for ( ; first1 != last1 && first2 != last2; void(++first1), void(++first2) )
    if (auto cmp = comp(*first1, *first2); cmp != 0)
        return cmp;
    return first1 != last1 ? std::strong_ordering::greater :
           first2 != last2 ? std::strong_ordering::less :
                             std::strong_ordering::equal;
2) 以下のように定義されているかのように動作します。
return std::lexicographical_compare_three_way(
    first1, last1, first2, last2, std::compare_three_way());

目次

[編集] 引数

first1, last1 - 調べる要素の1つめの範囲
first2, last2 - 調べる要素の2つめの範囲
comp - 関数オブジェクト型。 戻り値の型が3つの比較カテゴリ型 (strong_ordering、 weak_ordering、または partial_ordering) のいずれかでなければ、動作は未定義です
型の要件
-
InputIt1, InputIt2LegacyInputIterator の要件を満たさなければなりません。

[編集] 戻り値

上で定義されている通りの比較カテゴリ型。

[編集]

[編集] 関連項目

ある範囲が別の範囲より辞書的に小さいかどうか調べます
(関数テンプレート) [edit]
x <=> y を実装する関数オブジェクト
(クラス) [edit]