◐ Shell
clean mode source ↗

std::collate – cppreference.com

Aus cppreference.com

<metanoindex/>

<tbody> </tbody>

definiert in Header

<locale>

template< class CharT > class collate;

Klasse std::collate kapselt locale-spezifischen Zusammenstellung (Vergleich) und Hashing von Strings. Diese Facette durch std::basic_regex verwendet und können angewendet, mittels std::locale::operator() werden, direkt zu allen Standard-Algorithmen, die eine Zeichenfolge Vergleichsprädikat erwarten .

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.

cpp/locale/locale/facet

Inheritance diagram

Zwei Spezialisierungen werden durch die Standard-Bibliothek zur Verfügung gestellt und werden von allen locale Objekte in einem C + +-Programm erstellt implementiert:

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.

std::collate<char>

Geräte lexikographische Ordnung der Byte-Strings

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>

Geräte lexikographische Ordnung der breiten Strings

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.

Mitglied Typen

Mitglied Typ

Original:

Member type

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Definition
char_type charT
string_type std::basic_string<charT>

Member-Funktionen

baut eine neue Sortierfunktion Facette

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.


(öffentliche Elementfunktion)

zerstört sich eine Sortierfunktion Facette

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.


(geschützt Member-Funktion)

Beruft 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.


(öffentliche Elementfunktion) [edit]

Beruft 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.


(öffentliche Elementfunktion) [edit]

Beruft 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.


(öffentliche Elementfunktion) [edit]

Mitglied widerspricht

static std::locale::id id

ID des Gebietsschemas

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.


(öffentliche Member-Objekt)

Geschützt Member-Funktionen

[virtuell]

vergleicht zwei Strings mit dieser Facette der Kollatierung Regeln

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.


(virtuellen geschützten Member-Funktion) [edit]

[virtuell]

wandelt einen String, so dass collation durch Vergleich ersetzt werden können

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.


(virtuellen geschützten Member-Funktion) [edit]

[virtuell]

erzeugt einen Integer-Hash-Wert mit dieser Facette der Kollatierung Regeln

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.


(virtuellen geschützten Member-Funktion) [edit]

Beispiel

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

Output:

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

Siehe auch

lexicographically compares two strings using this locale's collate facet
(öffentliche Elementfunktion of std::locale) [edit]

schafft eine Sortierfunktion Facette für die benannte locale

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.


(Klassen-Template)