std::basic_string
| Dclar dans l'en-tte <string>
|
||
template< class CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT> > class basic_string; |
(1) | |
namespace pmr { template <class CharT, class Traits = std::char_traits<CharT>> using basic_string = std::basic_string< CharT, Traits, std::polymorphic_allocator<CharT>> } |
(2) | |
Le modle de classe basic_string stocke et manipule des squences de char ou objets similaires, qui ne sont pas des tableaux de types triviaux de disposition-standard. La classe ne dpend ni du type de caractre, ni de la nature des oprations sur ce type. Les dfinitions des oprations sont fournies par le paramtre de modle Traits - une spcialisation de std::char_traits ou une classe de traits compatibles.
Traits::char_type et CharT doivent dnommer le mme type; dans le cas contraire le programme est malform.
|
Les lments d'un |
(depuis C++11) |
std::basic_string satisfait les prrequis de AllocatorAwareContainer, SequenceContainer et ContiguousContainer (depuis C++17)
Plusieurs typedefs pour les types de caractres 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>
|
Parameters de modle
| CharT | - | type de caractre |
| Traits | - | classe de traits spcifiant les oprations sur le type de caractre |
| Allocator | - | type Allocator utilis pour allouer du stockage en interne |
Types membres
| Membre type | Dfinition |
traits_type
|
Traits
|
value_type
|
CharT
|
allocator_type
|
Allocator
|
size_type
|
Type intgral non sign (gnralement size_t)
|
difference_type
|
Type intgral sign (gnralement 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
|
Itrateur constant accs alatoire |
reverse_iterator
|
std::reverse_iterator<iterator>
|
const_reverse_iterator
|
std::reverse_iterator<const_iterator>
|
Fonctions membres
construit un basic_string (fonction membre publique) | |
(destructeur) |
dtrtuit le string, dsallouant le stockage interne si utilis (fonction membre publique) |
| assigne des valeurs la chane (fonction membre publique) | |
attribuer une chane de caractres 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) | |
Accs d'lment | |
| accde au caractre spcifi avec contrle de bornes (fonction membre publique) | |
| accde au caractre spcifi (fonction membre publique) | |
(C++11) |
accde au premier caractre (fonction membre publique) |
(C++11) |
accde au dernier caractre (fonction membre publique) |
| renvoie un pointeur vers le premier caractre d'une chane (fonction membre publique) | |
| retourne la chaine de caractre sous sa forme standard C non-modifiable (fonction membre publique) | |
(C++17) |
retourne une string_view non-modifiable de l'entiret de la chane de carcatres (fonction membre publique) |
Itrateurs | |
(C++11) |
retourne un itrateur au dbut 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 itrateur 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 itrateur inverse au dbut 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 itrateur 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 | |
vrifie si la chane 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 caractres 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) | |
| rserve du stockage (fonction membre publique) | |
retourne le nombre de caractres pouvant tre dtenus dans les stocks actuellement affects 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) |
rduit l'utilisation de la mmoire en librant la mmoire inutilise 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) |
Oprations | |
| efface le contenu (fonction membre publique) | |
insre des caractres 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 caractres 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 caractre 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 caractre 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 caractres 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 caractres 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 chanes 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) |
vrifie si la chane de caractres commence par le prfixe donn (fonction membre publique) |
(C++20) |
vtrifie si la chaine de caractres se termine par le suffixe donn (fonction membre publique) |
remplace chaque occurrence de caractres spcifis 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-chane 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 caractres 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 caractres stocks 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 caractres de la chane 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 dernire occurrence d'une chane 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 premire occurrence des caractres 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 premire absence de caractres 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 dernire occurrence de caractres 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 dernire absence de caractres 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 spciale. La signification exacte dpend 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) |
Fonctions annexes
concatne deux chanes ou une chane 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 gnrique) | |
compare lexicographiquement deux chanes 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 gnrique) | |
l'algorithme spcialis 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 gnrique) | |
| Efface tous les lments rpondants un critre spcifique (fonction gnrique) | |
D'entre / sortie | |
| effectue des oprations d'entre/sortie de flux sur des chaines de caractres (fonction gnrique) | |
lire des donnes depuis un flux d'E / S dans une chane 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 numriques | |
(C++11) (C++11) (C++11) |
convertit une chane 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 chane 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 chane en un nombre rel (fonction) |
(C++11) |
convertit une valeur entire ou relle en string (fonction) |
(C++11) |
convertit une valeur de point intgre 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) |
Litralles
Defined in namespace
std::literals::string_literals | |
(C++14) |
Convertis une litrale de tableau de caractres en basic_string (fonction) |
Classes d'aide
(C++11) (C++11) (C++11) (C++11) |
soutien de hachage pour chaines de caractres 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 gnrique spcialise) |