std:: wmemcmp
|
定義先ヘッダ
<cwchar>
|
||
|
int
wmemcmp
(
const
wchar_t
*
lhs,
const
wchar_t
*
rhs,
std::
size_t
count
)
;
|
||
最初の count 個のワイド文字を、 lhs と rhs が指すワイド文字配列間で比較します。比較は辞書順に行われます。
結果の符号は、比較対象の配列内で最初に異なるワイド文字の値の差の符号です。
count がゼロの場合、この関数は何も行いません。
目次 |
パラメータ
| lhs, rhs | - | 比較するワイド文字配列へのポインタ |
| count | - | 検査するワイド文字の数 |
戻り値
最初に異なるワイド文字の値が lhs において rhs の対応するワイド文字の値より小さい場合、負の値: lhs が rhs より辞書順で先行することを示す。
0 lhsとrhsのすべてのワイド文字が等しい場合。
**翻訳の説明:** - HTMLタグ、属性、`
`/`
`相当の要素内のテキストは翻訳せず保持
- C++用語(`count`, `lhs`, `rhs`)は原文のまま維持
- 自然な日本語表現で技術文書としての正確性を確保
- 原文の意味を忠実に伝える専門的な翻訳
最初に異なるワイド文字の値が lhs において rhs の対応するワイド文字の値より大きい場合、正の値: rhs が lhs より辞書順で前に来ることを示す。
注記
この関数はロケールに依存せず、検査対象の wchar_t オブジェクトの値に注意を払いません:ヌル文字および無効なワイド文字も同様に比較されます。
例
#include <clocale> #include <cwchar> #include <iostream> #include <locale> #include <string> void demo(const wchar_t* lhs, const wchar_t* rhs, std::size_t sz) { std::wcout << std::wstring(lhs, sz); int rc = std::wmemcmp(lhs, rhs, sz); if (rc == 0) std::wcout << " compares equal to "; else if (rc < 0) std::wcout << " precedes "; else if (rc > 0) std::wcout << " follows "; std::wcout << std::wstring(rhs, sz) << " in lexicographical order\n"; } int main() { std::setlocale(LC_ALL, "en_US.utf8"); std::wcout.imbue(std::locale("en_US.utf8")); wchar_t a1[] = {L'α',L'β',L'γ'}; constexpr std::size_t sz = sizeof a1 / sizeof *a1; wchar_t a2[sz] = {L'α',L'β',L'δ'}; demo(a1, a2, sz); demo(a2, a1, sz); demo(a1, a1, sz); }
出力例:
αβγ precedes αβδ in lexicographical order αβδ follows αβγ in lexicographical order αβγ compares equal to αβγ in lexicographical order
関連項目
|
2つのワイド文字列を比較する
(関数) |
|
|
2つのバッファを比較する
(関数) |
|
|
2つのワイド文字列から指定された数の文字を比較する
(関数) |
|
|
Cドキュメント
for
wmemcmp
|
|