Namespaces
Variants

std::experimental::basic_string_view<CharT,Traits>:: compare

From cppreference.net
constexpr int compare ( basic_string_view v ) const noexcept ;
(1) (ライブラリ基盤 TS)
constexpr int compare ( size_type pos1, size_type count1,
basic_string_view v ) const
(2) (ライブラリ基盤 TS)
constexpr int compare ( size_type pos1, size_type count1, basic_string_view v,
size_type pos2, size_type count2 ) const ;
(3) (ライブラリ基盤 TS)
constexpr int compare ( const CharT * s ) const ;
(4) (ライブラリ基盤 TS)
constexpr int compare ( size_type pos1, size_type count1,
const CharT * s ) const ;
(5) (ライブラリ基盤 TS)
constexpr int compare ( size_type pos1, size_type count1,
const CharT * s, size_type count2 ) const ;
(6) (ライブラリ基盤 TS)

2つの文字シーケンスを比較します。

1) 比較するシーケンスの長さ rlen は、 size ( ) v. size ( ) の小さい方です。この関数は2つのビューを比較するために traits :: compare ( data ( ) , v. data ( ) , rlen ) を呼び出し、以下の表に従って値を返します:
条件 結果 戻り値
Traits::compare(data(), v.data(), rlen ) < 0 this v より 小さい < 0
Traits::compare(data(), v.data(), rlen ) == 0 size() < v.size() this v より 小さい < 0
size() == v.size() this v 等しい 0
size() > v.size() this v より 大きい > 0
Traits::compare(data(), v.data(), rlen ) > 0 this v より 大きい > 0
2) 次と同等: substr ( pos1, count1 ) . compare ( v )
3) 次と同等: substr ( pos1, count1 ) . compare ( v. substr ( pos2, count2 ) )
4) compare ( basic_string_view ( s ) ) と等価。
5) 次と同等: substr ( pos1, count1 ) . compare ( basic_string_view ( s ) )
6) 次と等価 substr ( pos1, count1 ) . compare ( basic_string_view ( s, count2 ) )

目次

翻訳の説明: - 「Contents」を「目次」に翻訳しました - HTMLタグ、属性、 タグ内のテキスト(Parameters、Return value、Complexity、See also)はC++専門用語として翻訳せずに保持しました - すべてのHTML構造と書式は完全に保持されています - 数字やリンクなどの要素は変更していません

パラメータ

v - 比較対象のビュー
s - 比較対象の文字列へのポインタ
count1 - このビューの比較対象文字数
pos1 - このビューの比較対象最初の文字の位置
count2 - 指定されたビューの比較対象文字数
pos2 - 指定されたビューの比較対象最初の文字の位置

戻り値

このビューが他の文字シーケンスより小さい場合は負の値、両方の文字シーケンスが等しい場合はゼロ、このビューが他の文字シーケンスより大きい場合は正の値。

計算量

1) 比較される文字数に対して線形。

関連項目

2つのビューを辞書順で比較する
(関数テンプレート)