<string>

Définit la classe de modèle basic_string de conteneur et de différents modèles de prise en charge.

Pour plus d'informations sur basic_string, consultez basic_string Class.

namespace std {
    template<class CharType>
        class char_traits;
    template<>
        class char_traits<char>;
    template<>
        class char_traits<wchar_t>;
    template<>
        class char_traits<char16_t>; 
    template<>
        class char_traits<char32_t>;

    template<
        class CharType,
        class Traits = char_traits<CharType>,
        class Allocator = allocator<CharType> 
    > class basic_string;

    typedef basic_string<char> string;
    typedef basic_string<wchar_t> wstring;
    typedef basic_string<char16_t> u16string;
    typedef basic_string<char32_t> u32string;

        // NARROW FUNCTIONS
    int stoi (
        const string& _Str, 
        size_t *_Idx = 0,
        int _Base = 10
    );
    long stol (
        const string& _Str, 
        size_t *_Idx = 0,
        int _Base = 10
    );
    unsigned long stoul (
        const string& _Str, 
        size_t *_Idx = 0,
        int _Base = 10
    );
    long long stoll (
        const string& _Str, 
        size_t *_Idx = 0,
        int _Base = 10
    );
    unsigned long long stoull (
        const string& _Str, 
        size_t *_Idx = 0,
        int _Base = 10
    );
    float stof (
        const string& _Str, 
        size_t *_Idx = 0
    );
    double stod (
        const string& _Str, 
        size_t *_Idx = 0
    );
    long double stold (
        const string& _Str, 
        size_t *_Idx = 0
    );

    string to_string (long long _Val); 
    string to_string (unsigned long long _Val); 
    string to_string (long double _Val);

        // WIDE FUNCTIONS
    int stoi (
        const wstring& _Str, 
        size_t *_Idx = 0,
        int _Base = 10
    );
    long stol (
        const wstring& _Str, 
        size_t *_Idx = 0,
        int _Base = 10
    );
    unsigned long stoul (
        const wstring& _Str, 
        size_t *_Idx = 0,
        int _Base = 10
    );
    long long stoll (
        const wstring& _Str, 
        size_t *_Idx = 0,
        int _Base = 10
    );
    unsigned long long stoull (
        const wstring& _Str, 
        size_t *_Idx = 0,
        int _Base = 10
    ); 
    float stof (
        const wstring& _Str, 
        size_t *_Idx = 0
    ); 
    double stod (
        const wstring& _Str, 
        size_t *_Idx = 0
    );
    long double stold (
        const wstring& _Str, 
        size_t *_Idx = 0
    );
    wstring to_wstring (long long _Val); 
    wstring to_wstring (unsigned long long _Val); 
    wstring to_wstring (long double _Val);

       // TEMPLATE FUNCTIONS
    template<class CharType, class Traits, class Allocator>
        basic_string<CharType, Traits, Allocator> operator+ (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        basic_string<CharType, Traits, Allocator> operator+ (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const CharType *_Right
        );
    template<class CharType, class Traits, class Allocator>
        basic_string<CharType, Traits, Allocator> operator+ (
            const basic_string<CharType, Traits, Allocator>& _Left,
            CharType _Right
        );
    template<class CharType, class Traits, class Allocator>
        basic_string<CharType, Traits, Allocator> operator+ (
            const CharType *_Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        basic_string<CharType, Traits, Allocator> operator+ (
            CharType _Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );

    template<class CharType, class Traits, class Allocator>
        basic_string<CharType, Traits, Allocator>&& operator+ (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const basic_string<CharType, Traits, Allocator>&& _Right
        );
    template<class CharType, class Traits, class Allocator>
        basic_string<CharType, Traits, Allocator>&& operator+ (
            const basic_string<CharType, Traits, Allocator>&& _Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        basic_string<CharType, Traits, Allocator>&& operator+ (
            const basic_string<CharType, Traits, Allocator>&& _Left,
            const basic_string<CharType, Traits, Allocator>&& _Right
        );
    template<class CharType, class Traits, class Allocator> 
        basic_string<CharType, Traits, Allocator>&& operator+ (
            const basic_string<CharType, Traits, Allocator>&& _Left,
            const CharType *_Right
        );
    template<class CharType, class Traits, class Allocator>
        basic_string<CharType, Traits, Allocator>&& operator+ (
            const basic_string<CharType, Traits, Allocator>&& _Left,
            CharType _Right
        );
    template<class CharType, class Traits, class Allocator>
        basic_string<CharType, Traits, Allocator>&& operator+ (
            const CharType *_Left,
            const basic_string<CharType, Traits, Allocator>&& _Right
        );
    template<class CharType, class Traits, class Allocator>
        basic_string<CharType, Traits, Allocator>&& operator+ (
            CharType _Left,
            const basic_string<CharType, Traits, Allocator>&& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator== (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator== (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const CharType *_Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator== (
            const CharType *_Left, 
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator!= (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator!= (
            const basic_string<CharType, Traits, Allocator>& left,
            const CharType *_Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator!= (
            const CharType *_Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator< (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator< (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const CharType *_Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator< (
            const CharType *_Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator>= (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator>= (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const CharType *_Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator>= (
            const CharType *_Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator> (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator> (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const CharType *_Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator> (
            const CharType *_Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator<= (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator<= (
            const basic_string<CharType, Traits, Allocator>& _Left,
            const CharType *_Right
        );
    template<class CharType, class Traits, class Allocator>
        bool operator<= (
            const CharType *_Left,
            const basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        void swap (
            basic_string<CharType, Traits, Allocator>& _Left,
            basic_string<CharType, Traits, Allocator>& _Right
        );
    template<class CharType, class Traits, class Allocator>
        basic_ostream<CharType>& operator<< (
            basic_ostream<CharType>& _OStream,
            const basic_string<CharType, Traits, Allocator>& _Str
        );
    template<class CharType, class Traits, class Allocator>
        basic_istream<CharType>& operator>> (
            basic_istream<CharType>& _IStream,
            basic_string<CharType, Traits, Allocator>& _Str
        );
    template<class CharType, class Traits, class Allocator>
        basic_istream<CharType, Traits>& getline (
            basic_istream<CharType, Traits>& _IStream,
            basic_string<CharType, Traits, Allocator>& _Str
        );
     template<class CharType, class Traits, class Allocator>
        basic_istream<CharType, Traits>& getline (
            basic_istream<CharType, Traits>& _IStream,
            basic_string<CharType, Traits, Allocator>& _Str,
            CharType _Delimiter
        );
     template<class CharType, class Traits, class Allocator>
        basic_istream<CharType, Traits>& getline (
            basic_istream<CharType, Traits>&& _IStream,
            basic_string<CharType, Traits, Allocator>& _Str
        ); 
     template<class CharType, class Traits, class Allocator>
        basic_istream<CharType, Traits>& getline (
            basic_istream<CharType, Traits>&& _IStream,
            basic_string<CharType, Traits, Allocator>& _Str,
            CharType _Delimiter
        );
}  // namespace std

Paramètres

  • CharType
    Le paramètre de modèle qui décrit le type de données caractère.

  • Caractéristiques
    Le paramètre de modèle qui décrit toutes les propriétés de données caractères d' CharType .

  • Allocateur
    Le paramètre de modèle qui décrit l'objet stocké d'allocateur de mémoire.

  • _Str
    basic_string qui prend en charge les données caractères d' CharType .

  • _Val
    Valeur à convertir.

  • _Idx
    La valeur d'index du premier caractère inconverti.

  • _Base
    La base de numération à utiliser.

  • _IStream
    Le flux d'entrée qui prend en charge les données caractères d' CharType .

  • _OStream
    Le flux de sortie qui prend en charge les données caractères d' CharType .

  • _Delimiter
    Le séparateur de ligne.

  • _Left
    Les premiers conservés () comparer le paramètre, basic_string ou les données caractères.

  • _Right
    Le second (droite) comparer le paramètre, basic_string ou les données caractères.

Notes

Le langage C++ et la bibliothèque C++ standard prennent en charge deux types de chaînes :

  • Tableaux de caractères se terminant par null souvent appelés chaînes C.

  • La classe de modèle objets, du type basic_string, qui gèrent tous les arguments template comme d' char.

hd5zecz6.collapse_all(fr-fr,VS.110).gifTypedef

string

Un type qui décrit une spécialisation de la classe de modèle basic_string avec des éléments de type char comme string.

wstring

Un type qui décrit une spécialisation de la classe de modèle basic_string avec des éléments de type wchar_t comme wstring.

u16string

Un type qui décrit une spécialisation de la classe de modèle basic_string sur des éléments de type char16_t.

u32string

Un type qui décrit une spécialisation de la classe de modèle basic_string sur des éléments de type char32_t.

hd5zecz6.collapse_all(fr-fr,VS.110).gifOpérateurs

operator+

Concatène deux objets chaîne.

opérateur ! =

Teste si l'objet String située à gauche de l'opérateur n'est pas égal à l'objet String côté droit.

operator==

Teste si l'objet String située à gauche de l'opérateur est égal à l'objet String côté droit.

operator<

Teste si l'objet String située à gauche de l'opérateur est moins qu'à l'objet String côté droit.

operator<=

Teste si l'objet String située à gauche de l'opérateur est inférieure ou égale à l'objet String côté droit.

operator<<

Une fonction de modèle qui insère une chaîne dans le flux de sortie.

operator>

Teste si l'objet String située à gauche de l'opérateur est supérieur à l'objet String côté droit.

operator>=

Teste si l'objet String située à gauche de l'opérateur est supérieur ou égal à l'objet String côté droit.

operator>>

Une fonction de modèle qui récupère une chaîne du flux d'entrée.

hd5zecz6.collapse_all(fr-fr,VS.110).gifFonctions spécialisées de modèle

échange

Permute les tableaux de caractères de deux chaînes.

stod

Convertit une séquence de caractères à double.

stof

Convertit une séquence de caractères à float.

stoi

Convertit une séquence de caractères en un entier.

stold

Convertit une séquence de caractères à long double.

stoll

Convertit une séquence de caractères à long long.

stoul

Convertit une séquence de caractères à unsigned long.

stoull

Convertit une séquence de caractères à unsigned long long.

to_string

Convertit une valeur en string.

to_wstring

Convertit une valeur à stringlarge.

hd5zecz6.collapse_all(fr-fr,VS.110).gifFonctions

getline

Chaînes d'extrait du flux d'entrée ligne par ligne.

hd5zecz6.collapse_all(fr-fr,VS.110).gifClasses

basic_string Class

Une classe de modèle qui décrit les objets qui peuvent stocker une séquence d'objets caractère caractères arbitraires.

char_traits Struct

Une classe de modèle qui décrit les attributs associés à un caractère de type CharType

hd5zecz6.collapse_all(fr-fr,VS.110).gifSpécialisations

char_traits<char> Struct

Un struct qui est une spécialisation de la structure char_traits<CharType> de modèle à un élément de type char.

char_traits<wchar_t> Struct

Un struct qui est une spécialisation de la structure char_traits<CharType> de modèle à un élément de type wchar_t.

char_traits<char16_t> Struct

Un struct qui est une spécialisation de la structure char_traits<CharType> de modèle à un élément de type char16_t.

char_traits<char32_t> Struct

Un struct qui est une spécialisation de la structure char_traits<CharType> de modèle à un élément de type char32_t.

Configuration requise

  • en-tête : <string>

  • l'espace de noms : DST

Voir aussi

Référence

Sécurité des threads dans la bibliothèque C++ standard

Autres ressources

Fichiers d'en-tête