std::collate
De cppreference.com
[] |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Dclar dans l'en-tte <locale>
|
||
template< class CharT > class collate; |
||
Classe std::collate encapsule spcifique la localisation de classement (comparaison) et de hachage de chanes. Cette facette est utilis par std::basic_regex et peut tre appliqu, par l'intermdiaire d'
std::locale::operator(), directement tous les algorithmes standards qui attendent un prdicat de comparaison de chane .Original:
Class std::collate encapsulates locale-specific collation (comparison) and hashing of strings. This facet is used by std::basic_regex and can be applied, by means of
std::locale::operator(), directly to all standard algorithms that expect a string comparison predicate.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Inheritance diagram
Deux spcialisations sont fournis par la bibliothque standard et sont mises en uvre par tous les objets crs dans un environnement linguistique programme C + +:
Original:
Two specializations are provided by the standard library and are implemented by all locale objects created in a C++ program:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Defined in header
<locale> | |
std::collate<char>
|
outils ordre lexicographique des chanes d'octets
Original: implements lexicographical ordering of byte strings The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
std::collate<wchar_t>
|
outils ordre lexicographique des chanes larges
Original: implements lexicographical ordering of wide strings The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Types de membres
| Type du membre | Dfinition |
char_type
|
charT
|
string_type
|
std::basic_string<charT>
|
Fonctions membres
construit une nouvelle facette collate Original: constructs a new collate facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
Dtruit une facette collate Original: destructs a collate facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre protge) | |
Invoque do_compare Original: invokes do_compare The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
Invoque do_transform Original: invokes do_transform The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
Invoque do_hash Original: invokes do_hash The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
Objets membres
static std::locale::id id |
Id de la localisation Original: id of the locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (objet membre public) |
Protg fonctions membres
[ virtuel ]Original: virtual The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
compare deux chanes en utilisant les rgles de tri de cette facette Original: compares two strings using this facet's collation rules The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre virtuelle protge) |
[ virtuel ]Original: virtual The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
transforme une chane de classement de sorte que peut tre remplac par des comparaisons Original: transforms a string so that collation can be replaced by comparison The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre virtuelle protge) |
[ virtuel ]Original: virtual The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
gnre une valeur entire de hachage en utilisant les rgles de tri de cette facette Original: generates an integer hash value using this facet's collation rules The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre virtuelle protge) |
Exemple
#include <locale>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
int main()
{
std::wcout.imbue(std::locale(""));
std::vector<std::wstring> v = {L"ar", L"zebra", L"\u00f6grupp", L"Zebra", L"\u00e4ngel",
L"\u00e5r", L"f\u00f6rnamn"};
std::wcout << "Default locale collation order: ";
std::sort(v.begin(), v.end());
for(auto s : v) std::wcout << s << ' '; std::wcout << '\n';
std::wcout << "English locale collation order: ";
std::sort(v.begin(), v.end(), std::locale("en_US.UTF-8"));
for(auto s : v) std::wcout << s << ' '; std::wcout << '\n';
std::wcout << "Swedish locale collation order: ";
std::sort(v.begin(), v.end(), std::locale("sv_SE.UTF-8"));
for(auto s : v) std::wcout << s << ' '; std::wcout << '\n';
}
Rsultat :
Default locale collation order: Zebra ar frnamn zebra ngel r grupp
English locale collation order: ngel ar r frnamn grupp zebra Zebra
Swedish locale collation order: ar frnamn zebra Zebra r ngel grupp
Voir aussi
compare lexicographiquement deux chanes en utilisant les facettes de ce lieu de rassembler Original: lexicographically compares two strings using this locale's collate facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique de std::locale)
| |
cre une facette collate pour l'environnement local nomm Original: creates a collate facet for the named locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe gnrique) | |