std::lexicographical_compare_three_way
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <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, InputIt2 は LegacyInputIterator の要件を満たさなければなりません。
| ||
戻り値
上で定義されている通りの比較カテゴリ型。
例
| This section is incomplete Reason: no example |
関連項目
| ある範囲が別の範囲より辞書的に小さいかどうか調べます (関数テンプレート) | |
(C++20) |
x <=> y を実装する関数オブジェクト (クラス) |