<string>

Definiert die Containervorlagenklasse basic_string und die verschiedenen unterstützenden Vorlagen.

Weitere Informationen zu basic_string finden Sie unter 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

Parameter

  • CharType
    Der Vorlagenparameter, der den Zeichendatentyp beschreibt.

  • Features
    Der Vorlagenparameter, der alle Eigenschaften der CharType Textdaten beschrieben wird.

  • Belegungsfunktion
    Der Vorlagenparameter, der die gespeicherte Speicherbelegungsfunktionsobjekt beschreibt.

  • _Str
    basic_string, das CharType Textdaten unterstützt.

  • _Val
    Der zu konvertierende Wert.

  • _Idx
    Der Indexwert des ersten Zeichens ohne.

  • _Base
    Die zu verwendende Basis.

  • _IStream
    Der Eingabestream, der CharType Textdaten unterstützt.

  • _OStream
    Der Ausgabestream, der CharType Textdaten unterstützt.

  • _Delimiter
    Das Zeilentrennzeichen.

  • _Left
    Die ersten (links) vergleichen, Parameter entweder basic_string oder Textdaten.

  • _Right
    Das zweite (rechts) vergleichen, Parameter entweder basic_string oder Textdaten.

Hinweise

Die Programmiersprache C++ und Typen der C++-Standardbibliothek-Unterstützungs zwei von Zeichenfolgen:

  • Auf NULL endende Zeichenarrays häufig wird als C-Zeichenfolgen.

  • Vorlagenklasse bezieht, vom Typ basic_string ein, das alle ähnlichen Vorlagenargumente char behandeln.

hd5zecz6.collapse_all(de-de,VS.110).gifTypedefs

string

Ein Typ, der eine Spezialisierung der Vorlagenklasse basic_string mit Elementen des Typs char als string beschreibt.

wstring

Ein Typ, der eine Spezialisierung der Vorlagenklasse basic_string mit Elementen des Typs wchar_t als wstring beschreibt.

u16string

Ein Typ, der eine Spezialisierung der Vorlagenklasse basic_string auf Grundlage Elemente des Typs char16_t beschreibt.

u32string

Ein Typ, der eine Spezialisierung der Vorlagenklasse basic_string auf Grundlage Elemente des Typs char32_t beschreibt.

hd5zecz6.collapse_all(de-de,VS.110).gifOperatoren

operator+

Verkettet zwei Zeichenfolgenobjekte.

Operator! =

Tests, wenn das Zeichenfolgenobjekt auf der linken Seite des Operators nicht gleich das Zeichenfolgenobjekt auf der rechten Seite ist.

operator==

Tests, wenn das Zeichenfolgenobjekt auf der linken Seite des Operators gleich das Zeichenfolgenobjekt auf der rechten Seite ist.

operator<

Tests, wenn das Zeichenfolgenobjekt auf der linken Seite des Operators kleiner als dem Zeichenfolgenobjekt auf der rechten Seite ist.

operator<=

Tests, wenn das Zeichenfolgenobjekt auf der linken Seite des Operators kleiner oder gleich dem Zeichenfolgenobjekt auf der rechten Seite ist.

operator<<

Eine Vorlagenfunktion, die eine Zeichenfolge in den Ausgabestream einfügt.

operator>

Tests, wenn das Zeichenfolgenobjekt auf der linken Seite des Operators größer als dem Zeichenfolgenobjekt auf der rechten Seite ist.

operator>=

Tests, wenn das Zeichenfolgenobjekt auf der linken Seite des Operators größer oder gleich dem Zeichenfolgenobjekt auf der rechten Seite ist.

operator>>

Eine Vorlagenfunktion, die eine Zeichenfolge im Eingabestream extrahiert.

hd5zecz6.collapse_all(de-de,VS.110).gifSpezialisierte Vorlagen-Funktionen

Austausch

Tauscht die Arrays von Zeichen aus zwei Zeichenfolgen aus.

stod

Konvertiert eine Zeichenfolge zu double.

stof

Konvertiert eine Zeichenfolge zu float.

stoi

Konvertiert eine Zeichenfolge in eine ganze Zahl.

stold

Konvertiert eine Zeichenfolge zu long double.

stoll

Konvertiert eine Zeichenfolge zu long long.

stoul

Konvertiert eine Zeichenfolge zu unsigned long.

stoull

Konvertiert eine Zeichenfolge zu unsigned long long.

to_string

Konvertiert einen Wert in einen string.

to_wstring

Konvertiert einen Wert zu großen string.

hd5zecz6.collapse_all(de-de,VS.110).gifFunktionen

getline

Auszugzeichenfolgen im Eingabestream zeilenweise.

hd5zecz6.collapse_all(de-de,VS.110).gifKlassen

basic_string Class

Eine Vorlagenklasse, die Objekte beschrieben, die eine Sequenz von beliebigen Zeichen ähnlichen Objekten speichern können.

char_traits Struct

Eine Vorlagenklasse, die die Attribute beschrieben, die mit einem Zeichen des Typs CharType zugeordnet sind

hd5zecz6.collapse_all(de-de,VS.110).gifSpezialisierungen

char_traits<char> Struct

Eine Struktur, die eine Spezialisierung der Vorlagenstruktur char_traits<CharType> auf ein Element des Typs char ist.

char_traits<wchar_t> Struct

Eine Struktur, die eine Spezialisierung der Vorlagenstruktur char_traits<CharType> auf ein Element des Typs wchar_t ist.

char_traits<char16_t> Struct

Eine Struktur, die eine Spezialisierung der Vorlagenstruktur char_traits<CharType> auf ein Element des Typs char16_t ist.

char_traits<char32_t> Struct

Eine Struktur, die eine Spezialisierung der Vorlagenstruktur char_traits<CharType> auf ein Element des Typs char32_t ist.

Anforderungen

  • Header: <string>

  • Namespace: std

Siehe auch

Referenz

Threadsicherheit in der C++-Standardbibliothek

Weitere Ressourcen

Headerdateien