std::basic_string
Déclaré dans l'en-tête <string>
|
||
template< class CharT, |
(1) | |
namespace pmr { template <class CharT, class Traits = std::char_traits<CharT>> |
(2) | |
Le modèle de classe basic_string
stocke et manipule des séquences de char ou objets similaires, qui ne sont pas des tableaux de types triviaux de disposition-standard. La classe ne dépend ni du type de caractère, ni de la nature des opérations sur ce type. Les définitions des opérations sont fournies par le paramètre de modèle Traits
- une spécialisation de std::char_traits ou une classe de traits compatibles.
Traits::char_type
et CharT
doivent dénommer le même type; dans le cas contraire le programme est malformé.
Les éléments d'un |
(depuis C++11) |
std::basic_string
satisfait les prérequis de AllocatorAwareContainer, SequenceContainer et ContiguousContainer (depuis C++17)
Plusieurs typedefs pour les types de caractères communs sont fournies:
Defined in header
<string> | |
Type | Definition |
std::string | std::basic_string<char> |
std::wstring | std::basic_string<wchar_t> |
std::u8string (C++20) | std::basic_string<char8_t> |
std::u16string (C++11) | std::basic_string<char16_t> |
std::u32string (C++11) | std::basic_string<char32_t> |
std::pmr::string (C++17) | std::pmr::basic_string<char> |
std::pmr::wstring (C++17) | std::pmr::basic_string<wchar_t> |
std::pmr::u8string (C++20) | std::pmr::basic_string<char8_t> |
std::pmr::u16string (C++17) | std::pmr::basic_string<char16_t> |
std::pmr::u32string (C++17) | std::pmr::basic_string<char32_t> |
Sommaire |
[modifier] Parameters de modèle
CharT | - | type de caractère |
Traits | - | classe de traits spécifiant les opérations sur le type de caractère |
Allocator | - | type Allocator utilisé pour allouer du stockage en interne |
[modifier] Types membres
Membre type | Définition |
traits_type
|
Traits
|
value_type
|
CharT
|
allocator_type
|
Allocator
|
size_type
|
Type intégral non signé (généralement size_t) |
difference_type
|
Type intégral signé (généralement ptrdiff_t) |
reference
|
Allocator::reference (avant C++11)value_type& (depuis C++11)
|
const_reference
|
Allocator::const_reference (avant C++11)const value_type& (depuis C++11)
|
pointer
|
Allocator::pointer (avant C++11)std::allocator_traits<Allocator>::pointer (depuis C++11) |
const_pointer
|
Allocator::const_pointer (avant C++11) std::allocator_traits<Allocator>::const_pointer (depuis C++11) |
iterator
|
RandomAccessIterator
|
const_iterator
|
Itérateur constant à accès aléatoire |
reverse_iterator
|
std::reverse_iterator<iterator> |
const_reverse_iterator
|
std::reverse_iterator<const_iterator> |
[modifier] Fonctions membres
construit un basic_string (fonction membre publique) | |
(destructeur) |
détrtuit le string, désallouant le stockage interne si utilisé (fonction membre publique) |
assigne des valeurs à la chaîne (fonction membre publique) | |
attribuer à une chaîne de caractères Original: assign characters to a string 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) | |
renvoie l'allocateur associé Original: returns the associated allocator 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) | |
Accès d'élément | |
accède au caractère spécifié avec contrôle de bornes (fonction membre publique) | |
accède au caractère spécifié (fonction membre publique) | |
(C++11) |
accède au premier caractère (fonction membre publique) |
(C++11) |
accède au dernier caractère (fonction membre publique) |
renvoie un pointeur vers le premier caractère d'une chaîne (fonction membre publique) | |
retourne la chaine de caractère sous sa forme standard C non-modifiable (fonction membre publique) | |
(C++17) |
retourne une string_view non-modifiable de l'entièreté de la chaîne de carcatères (fonction membre publique) |
Itérateurs | |
(C++11) |
retourne un itérateur au début Original: returns an iterator to the beginning 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) |
(C++11) |
retourne un itérateur à la fin Original: returns an iterator to the end 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) |
(C++11) |
retourne un itérateur inverse au début Original: returns a reverse iterator to the beginning 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) |
(C++11) |
retourne un itérateur inverse à la fin Original: returns a reverse iterator to the end 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) |
Capacité | |
vérifie si la chaîne est vide Original: checks whether the string is empty 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) | |
returns the number of characters (fonction membre publique) | |
retourne le nombre maximal de caractères Original: returns the maximum number of characters 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) | |
réserve du stockage (fonction membre publique) | |
retourne le nombre de caractères pouvant être détenus dans les stocks actuellement affectés Original: returns the number of characters that can be held in currently allocated storage 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) | |
(C++11) |
réduit l'utilisation de la mémoire en libérant la mémoire inutilisée Original: reduces memory usage by freeing unused memory 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) |
Opérations | |
efface le contenu (fonction membre publique) | |
insère des caractères Original: inserts characters 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) | |
supprime les caractères Original: removes characters 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) | |
ajoute un caractère à la fin Original: appends a character to the end 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) | |
(C++11) |
supprime le dernier caractère Original: removes the last character 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) |
ajoute des caractères à la fin Original: appends characters to the end 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) | |
ajoute des caractères à la fin Original: appends characters to the end 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) | |
compare deux chaînes Original: compares two strings 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) | |
(C++20) |
vérifie si la chaîne de caractères commence par le préfixe donné (fonction membre publique) |
(C++20) |
vétrifie si la chaine de caractères se termine par le suffixe donné (fonction membre publique) |
remplace chaque occurrence de caractères spécifiés Original: replaces every occurrence of specified characters 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) | |
renvoie une sous-chaîne Original: returns a substring 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) | |
copies caractères Original: copies characters 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) | |
modifie le nombre de caractères stockés Original: changes the number of characters stored 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) | |
permute les contenus Original: swaps the contents 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) | |
Recherche | |
trouver des caractères de la chaîne Original: find characters in the string 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) | |
trouver la dernière occurrence d'une chaîne Original: find the last occurrence of a substring 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) | |
trouver la première occurrence des caractères Original: find first occurrence of characters 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) | |
trouver la première absence de caractères Original: find first absence of characters 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) | |
trouver la dernière occurrence de caractères Original: find last occurrence of characters 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) | |
trouver une dernière absence de caractères Original: find last absence of characters 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) | |
Constantes | |
[ statique ]Original: static The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
valeur spéciale. La signification exacte dépend du contexte Original: special value. The exact meaning depends on the context The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante membre statique publique) |
[modifier] Fonctions annexes
concatène deux chaînes ou une chaîne et un char Original: concatenates two strings or a string and a char The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction générique) | |
compare lexicographiquement deux chaînes Original: lexicographically compares two strings The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction générique) | |
l'algorithme spécialisé std::swap Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction générique) | |
Efface tous les éléments répondants à un critère spécifique (fonction générique) | |
D'entrée / sortie | |
effectue des opérations d'entrée/sortie de flux sur des chaines de caractères (fonction générique) | |
lire des données depuis un flux d'E / S dans une chaîne Original: read data from an I/O stream into a string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |
Conversions numériques | |
(C++11) (C++11) (C++11) |
convertit une chaîne en un entier signé Original: converts a string to an signed integer The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) |
(C++11) (C++11) |
convertit une chaîne en un entier non signé Original: converts a string to an unsigned integer The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) |
(C++11) (C++11) (C++11) |
convertit une chaîne en un nombre réel (fonction) |
(C++11) |
convertit une valeur entière ou réelle en string (fonction) |
(C++11) |
convertit une valeur de point intégrée ou flottante wstring Original: converts an integral or floating point value to wstring The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) |
[modifier] Litéralles
Defined in namespace
std::literals::string_literals | |
(C++14) |
Convertis une litérale de tableau de caractères en basic_string (fonction) |
[modifier] Classes d'aide
(C++11) (C++11) (C++11) (C++11) |
soutien de hachage pour chaines de caractères Original: hash support for 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 spécialisée) |