std::regex_traits::transform_primary
De cppreference.com
< cpp | regex | regex traits
![]() |
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. |
template< class ForwardIt > string_type transform_primary( ForwardIt first, ForwardIt last) const |
||
Obtient la clé de tri primaire (en ignorant les casses, les signes diacritiques, variant, etc) pour la séquence de caractères
[first, last)
, de sorte que si une clé de tri primaire compare inférieure à une autre clé de tri primaire avec operator<, la séquence de caractères qui a produit la première clé de tri vient avant la séquence de caractères qui a produit la deuxième clé de tri, afin de la locale courante imprégnée de collecte primaire .Original:
Obtains the primary (ignoring case, diacritics, variant, etc) sort key for the character sequence
[first, last)
, such that if a primary sort key compares less than another primary sort key with operator<, then the character sequence that produced the first sort key comes before the character sequence that produced the second sort key, in the currently imbued locale's primary collation order.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.
La bibliothèque regex utilise ce caractère pour correspondre personnages contre les classes d'équivalence. Par exemple, le [[=a=]] regex est équivalent au caractère
c1
si traits.transform_primary(c1) est équivalent à traits.transform_primary("a") (ce qui est vrai pour n'importe quel c1
de "AÀÁÂÃÄÅaàáâãäå"). Notez que transform_primary()
prend un argument séquence de caractères, car les classes d'équivalence peuvent être multicaractères, comme [[=ll=]] .Original:
The regex library uses this trait to match characters against equivalence classes. For example, the regex [[=a=]] is equivalent to the character
c1
if traits.transform_primary(c1) is equivalent to traits.transform_primary("a") (which is true for any c1
from "AÀÁÂÃÄÅaàáâãäå"). Note that transform_primary()
takes a character sequence argument because equivalence classes may be multicharacter, such as [[=ll=]].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.
Il n'y a pas de moyen portable de définir la clé de tri primaire en termes de std::locale depuis la conversion de la clé de collation retourné par std::collate::transform() à la clé primaire d'équivalence est spécifique à la localisation, et si l'utilisateur remplace la facette std::collate, que la conversion n'est plus connu à la bibliothèque standard de std::regex_traits. Spécialisations de la bibliothèque standard de std::regex_traits retourner une chaîne vide, sauf si la facette std::collate de la localisation actuellement imprégnée n'a pas été remplacé par l'utilisateur, et correspond toujours à la facette fourni par le système std::collate), dans lequel std::collate_byname<charT>::transform(first, last) cas est exécutée et la clé de tri qu'il produit est converti à la clé de tri primaire prévue en utilisant une conversion spécifique à la localisation .
Original:
There is no portable way to define primary sort key in terms of std::locale since the conversion from the collation key returned by std::collate::transform() to the primary equivalence key is locale-specific, and if the user replaces the std::collate facet, that conversion is no longer known to the standard library's std::regex_traits. Standard library specializations of std::regex_traits return an empty string unless the std::collate facet of the currently-imbued locale was not replaced by the user, and still matches the system-supplied std::collate facet), in which case std::collate_byname<charT>::transform(first, last) is executed and the sort key it produces is converted to the expected primary sort key using a locale-specific conversion.
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.
[modifier] Paramètres
first, last | - | une paire d'itérateurs qui détermine la séquence de caractères à comparer
Original: a pair of iterators which determines the sequence of characters to compare The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Type requirements | ||
-ForwardIt must meet the requirements of ForwardIterator .
|
[modifier] Retourne la valeur
La clé de tri primaire pour la
[first, last)
séquence de caractères dans la locale courante imprégnés, ignorant cas, la variante, les signes diacritiques, etc Original:
The primary sort key for the character sequence
[first, last)
in the currently imbued locale, ignoring case, variant, diacritics, etc. 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.
[modifier] Exemple
Présente la fonction regex qui fonctionne grâce à transform_primary ()
Original:
Demonstrates the regex feature that works through transform_primary()
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.
#include <iostream> #include <regex> int main() { std::locale::global(std::locale("en_US.UTF-8")); std::wstring str = L"AÀÁÂÃÄÅaàáâãäå"; std::wregex re(L"[[=a=]]*", std::regex::basic); std::cout << std::boolalpha << std::regex_match(str, re) << '\n'; }
Résultat :
true
This section is incomplete Reason: could use an example with user-defined regex_traits supplying user-defined transform_primary |