名前空間
変種
操作

std::locale::operator()

提供: cppreference.com
< cpp‎ | locale‎ | locale

 
 
ローカライゼーションライブラリ
ロケールおよびファセット
Original:
Locales and facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
locale
文字分類
Original:
Character classification
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
変換
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファセットカテゴリの基底クラスです
Original:
Facet category base classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファセットカテゴリ
Original:
Facet categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ロケール固有のファセット
Original:
Locale-specific facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
コー​​ド変換ファセット
Original:
Code conversion facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
codecvt_utf8(C++11)
codecvt_utf16(C++11)
Cロケール
Original:
C locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
std::locale
メンバータイプ
Original:
Member types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
locale::id
locale::facet
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
locale::locale
locale::~locale
locale::operator=
locale::combine
locale::name
locale::operator==
locale::operator!=
locale::operator()
静的メンバ関数
Original:
Static member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
locale::global
locale::classic
 
template< class CharT, class Traits, class Alloc >

bool operator()( const basic_string<CharT,Traits,Alloc>& s1,

                 const basic_string<CharT,Traits,Alloc>& s2) const;
s1s2このロケールのstd::collate<charT>ファセットによって定義された辞書式の比較ルールに従って、二つの文字列引数を比較します。この演算子は、標準的なアルゴリズムでバイナリ述語(例えばstd::sortなど)と命じたコンテナ(例えばstd::setなど)として使用される照合ファセットを持つ任意のロケールオブジェクトを可能にします
Original:
Compares two string arguments s1 and s2 according to the lexicographic comparison rules defined by this locale's std::collate<charT> facet. This operator allows any locale object that has a collate facet to be used as a binary predicate in the standard algorithms (such as std::sort) and ordered containers (such as std::set)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

s1 -
比較する最初の文字列
Original:
the first string to compare
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
s2 -
比較する2番目の文字列
Original:
the second string to compare
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

trues1s2より辞書式に小さい場合は、falseその他のとき.
Original:
true if s1 is lexicographically less than s2, false otherwise.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 可能な実装

template<class CharT, class Traits, class Alloc >
bool operator()(const std::basic_string<CharT,Traits,Alloc>& s1,
                const std::basic_string<CharT,Traits,Alloc>& s2) const;
{
    return std::use_facet<std::collate<GharT>>(*this).compare(
                                         s1.data(), s1.data() + s1.size(),
                                         s2.data(), s2.data() + s2.size()   ) < 0;
}

[編集]

文字列のベクトルをコンパレータとしてロケールオブジェクトを使用してデフォルト以外のロケールに従ってソートすることができます
Original:
A vector of strings can be sorted according to a non-default locale by using the locale object as comparator:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <locale>
#include <algorithm>
#include <vector>
#include <string>
#include <cassert>
 
int main()
{
    std::vector<std::wstring> v = {L"жил", L"был", L"кот"};
    std::sort(v.begin(), v.end(), std::locale("ru_RU.UTF8"));
    assert(v[0] == L"был");
    assert(v[1] == L"жил");
    assert(v[2] == L"кот");
}


[編集] も参照してください

文字列の比較とハッシュを辞書式が定義されています
Original:
defines lexicographical comparison and hashing of strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(クラステンプレート) [edit]