Espaces de noms
Variantes
Affichages
Actions

std::locale::operator()

De cppreference.com
< cpp‎ | locale‎ | locale

 
 
Bibliothèque localisations
Locales et facettes
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
Classification des caractères
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.
Conversions
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Classes de facettes catégorie de base
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.
Catégories de facettes
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.
Spécifique aux paramètres régionaux facettes
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.
Facettes de conversion de code
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 locale
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
Types de membres
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
Les fonctions membres
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()
Fonctions membres statiques
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;
Compare deux arguments de chaîne s1 et s2 selon les règles de comparaison lexicographique définies par facette std::collate<charT> cette environnement local. Cet opérateur permet à tout objet qui possède un lieu d'assemblage facette à être utilisé comme un prédicat binaire dans les algorithmes standard (tel que std::sort) et des conteneurs (classés comme 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.

Sommaire

[modifier] Paramètres

s1 -
la première chaîne à comparer
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 -
la deuxième chaîne à comparer
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.

[modifier] Retourne la valeur

true si s1 est lexicographiquement inférieur à s2, false autrement .
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.

[modifier] Mise en œuvre possible

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;
}

[modifier] Exemple

Un vecteur de chaînes de caractères peuvent être triées en fonction de paramètres régionaux non par défaut en utilisant l'objet locale de comparateur:
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"кот");
}


[modifier] Voir aussi

définit comparaison lexicographique et le hachage de chaînes
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.

(classe générique) [edit]