Espaces de noms
Variantes
Affichages
Actions

std::basic_string

De cppreference.com
< cpp‎ | string
 
 
Bibliothèque de chaînes de caractères
Chaînes à zéro terminal
Original:
Null-terminated strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Les chaînes d'octets
Chaines multi-octets
Les chaînes étendues
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string
char_traits
 
std::basic_string
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.
basic_string::basic_string
basic_string::operator=
basic_string::assign
basic_string::get_allocator
Elément d'accès
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::at
basic_string::operator[]
basic_string::front (C++11)
basic_string::back (C++11)
basic_string::data
basic_string::c_str
Les itérateurs
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::begin
basic_string::cbegin

(C++11)
basic_string::end
basic_string::cend

(C++11)
basic_string::rbegin
basic_string::crbegin

(C++11)
basic_string::rend
basic_string::crend

(C++11)
Capacité
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::empty
basic_string::size
basic_string::length
basic_string::max_size
basic_string::reserve
basic_string::capacity
basic_string::shrink_to_fit (C++11)
Opérations
Original:
Operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::clear
basic_string::insert
basic_string::erase
basic_string::push_back
basic_string::pop_back (C++11)
basic_string::append
basic_string::operator+=
basic_string::compare
basic_string::replace
basic_string::substr
basic_string::copy
basic_string::resize
basic_string::swap
Recherche
Original:
Search
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::find
basic_string::rfind
basic_string::find_first_of
basic_string::find_first_not_of
basic_string::find_last_of
basic_string::find_last_not_of
Constantes
Original:
Constants
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::npos
Tiers fonctions
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator+
operator==
operator!=
operator<
operator>
operator<=
operator>=
swap(std::basic_string)
operator<<
operator>>
getline
stoi
stol
stoll
(C++11)
(C++11)
(C++11)
stoul
stoull
(C++11)
(C++11)
stof
stod
stold
(C++11)
(C++11)
(C++11)
to_string (C++11)
to_wstring (C++11)
Classes d'aide
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
hash<std::string>
hash<std::wstring>
hash<std::u32string>
hash<std::u16string>
(C++11)
 
Déclaré dans l'en-tête <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 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 basic_string sont stockés de manière contiguë, ce qui signifie que pour une basic_string s, &*(s.begin() + n) == &*s.begin() + n pour tout n dans [0, s.size()), ou, de manière équivalente, un pointeur vers s[0] peut être passé à des fonctions que attendent un pointeur vers le premier élément d'un tableau charT[].

(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 [edit]
size_type Type intégral non signé (généralement size_t)[edit]
difference_type Type intégral signé (généralement ptrdiff_t) [edit]
reference Allocator::reference (avant C++11)
value_type& (depuis C++11) [edit]
const_reference Allocator::const_reference (avant C++11)
const value_type& (depuis C++11) [edit]
pointer Allocator::pointer (avant C++11)
std::allocator_traits<Allocator>::pointer (depuis C++11) [edit]
const_pointer Allocator::const_pointer (avant C++11)
std::allocator_traits<Allocator>::const_pointer (depuis C++11) [edit]
iterator RandomAccessIterator [edit]
const_iterator Itérateur constant à accès aléatoire [edit]
reverse_iterator std::reverse_iterator<iterator> [edit]
const_reverse_iterator std::reverse_iterator<const_iterator> [edit]

[modifier] Fonctions membres

construit un basic_string
(fonction membre publique) [edit]
(destructeur)
détrtuit le string, désallouant le stockage interne si utilisé
(fonction membre publique)
assigne des valeurs à la chaîne
(fonction membre publique) [edit]
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) [edit]
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) [edit]
Accès d'élément
accède au caractère spécifié avec contrôle de bornes
(fonction membre publique) [edit]
accède au caractère spécifié
(fonction membre publique) [edit]
(C++11)
accède au premier caractère
(fonction membre publique) [edit]
(C++11)
accède au dernier caractère
(fonction membre publique) [edit]
renvoie un pointeur vers le premier caractère d'une chaîne
(fonction membre publique) [edit]
retourne la chaine de caractère sous sa forme standard C non-modifiable
(fonction membre publique) [edit]
retourne une string_view non-modifiable de l'entièreté de la chaîne de carcatères
(fonction membre publique) [edit]
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) [edit]

(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) [edit]
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) [edit]

(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) [edit]
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) [edit]
returns the number of characters
(fonction membre publique) [edit]
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) [edit]
réserve du stockage
(fonction membre publique) [edit]
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) [edit]
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) [edit]
Opérations
efface le contenu
(fonction membre publique) [edit]
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) [edit]
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) [edit]
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) [edit]
(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) [edit]
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) [edit]
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) [edit]
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) [edit]
(C++20)
vérifie si la chaîne de caractères commence par le préfixe donné
(fonction membre publique) [edit]
(C++20)
vétrifie si la chaine de caractères se termine par le suffixe donné
(fonction membre publique) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]

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) [edit]

[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) [edit]
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) [edit]
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) [edit]
Efface tous les éléments répondants à un critère spécifique
(fonction générique) [edit]
D'entrée / sortie
effectue des opérations d'entrée/sortie de flux sur des chaines de caractères
(fonction générique) [edit]
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) [edit]
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) [edit]
(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) [edit]
(C++11)
(C++11)
(C++11)
convertit une chaîne en un nombre réel
(fonction) [edit]
(C++11)
convertit une valeur entière ou réelle en string
(fonction) [edit]
(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) [edit]

[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) [edit]

[modifier] Classes d'aide

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) [edit]

[modifier] Guides de déduction (depuis C++17)