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>| Déclaré dans l'en-tête <locale>
|
||
template< class CharT > class collate; |
||
Classe std::collate encapsule spécifique à la localisation de classement (comparaison) et de hachage de chaînes. Cette facette est utilisé par std::basic_regex et peut être appliqué, par l'intermédiaire d'
std::locale::operator(), directement à tous les algorithmes standards qui attendent un prédicat de comparaison de chaîne .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 spécialisations sont fournis par la bibliothèque standard et sont mises en œuvre par tous les objets créés 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 chaînes 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 chaînes 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 | Définition |
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) | |
Détruit 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 protégée) | |
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) |
Protégé 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 chaînes en utilisant les règles 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 protégée) |
[ 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 chaîne 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 protégée) |
[ 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. |
génère une valeur entière de hachage en utilisant les règles 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 protégée) |
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';
}
Résultat :
Default locale collation order: Zebra ar förnamn zebra ängel år ögrupp
English locale collation order: ängel ar år förnamn ögrupp zebra Zebra
Swedish locale collation order: ar förnamn zebra Zebra år ängel ögrupp
Voir aussi
compare lexicographiquement deux chaînes 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)
| |
crée 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 générique) | |