文字列 "より小さい" 比較用関数オブジェクト
[詳解]
std::binary_function< std::string, std::string, bool >を継承しています。
|
| Less (bool nCase=false) |
| 大文字・小文字を無視するかを指定して構築 [詳解]
|
|
bool | operator() (const std::string &s1, const std::string &s2) const |
| s1 の方が小さければ true を返す [詳解]
|
|
文字列 "より小さい" 比較用関数オブジェクト
アルゴリズムで利用することを想定している。 例えば、大文字・小文字を無視して文字列の比較をした上でソートしたい場合は次のようにすればよい。
std::vector< std::string > str;
:
std::sort( str.begin(), str.end(), tadah_fussy::string::Less( true ) );
◆ Less()
tadah_fussy::string_lib::Less::Less |
( |
bool |
nCase = false | ) |
|
|
inline |
大文字・小文字を無視するかを指定して構築
- 引数
-
nCase | 大文字・小文字を無視するなら true にする |
◆ operator()()
bool tadah_fussy::string_lib::Less::operator() |
( |
const std::string & |
s1, |
|
|
const std::string & |
s2 |
|
) |
| const |
|
inline |
s1 の方が小さければ true を返す
二つの文字列を先頭から順に比較し、不一致を見つけたら、s1 の文字コードの方が s2 より小さければ true、 逆の場合は false を返す。もしどちらかが末尾まで達した場合、s1 の方が短ければ true、 それ以外の場合は false を返す。ignoreCase が true なら、大文字と小文字の違いは無視される。
- 引数
-
- 戻り値
- s1 < s2 なら true を返す
この構造体詳解は次のファイルから抽出されました: