다음을 통해 공유


<string>

컨테이너 클래스 템플릿 정의 basic_string 및 지원 다양 한 템플릿.

basic_string에 대한 자세한 내용은 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

매개 변수

  • CharType
    문자 데이터 형식에 설명 하는 템플릿 매개 변수입니다.

  • 성분
    모든 속성에 설명 하는 템플릿 매개 변수는 CharType 문자 데이터.

  • 할당자
    저장된 메모리 할당 기 개체를 설명 하는 템플릿 매개 변수입니다.

  • _Str
    basic_string 는 지원 CharType 문자 데이터.

  • _Val
    변환될 값입니다.

  • _Idx
    변환 되지 않은 첫 번째 문자의 인덱스 값입니다.

  • _Base
    사용 하 여 숫자 기본입니다.

  • _IStream
    지 원하는 입력된 스트림의 CharType 문자 데이터.

  • _OStream
    출력 스트림을 지 원하는 CharType 문자 데이터.

  • _Delimiter
    줄 구분 기호입니다.

  • _Left
    (왼쪽) 첫 번째 매개 변수는 비교에 basic_string 또는 문자 데이터.

  • _Right
    두 번째 (오른쪽) 비교 매개 변수 중 하나는 basic_string 또는 문자 데이터.

설명

C + + 언어와 표준 C++ 라이브러리 문자열의 두 가지를 지원 합니다.

  • Null로 끝나는 배열으로 C 문자열이 라고도 합니다.

  • 템플릿 클래스 개체 형식의 basic_string, 모든 핸들 char-템플릿 인수를 다음과 같이 합니다.

hd5zecz6.collapse_all(ko-kr,VS.110).gif형식 정의

string

템플릿 클래스의 특수화에 설명 하는 형식 basic_string 형식 요소의 char 으로 string.

wstring

템플릿 클래스의 특수화에 설명 하는 형식 basic_string 형식 요소의 wchar_t 으로 wstring.

u16string

템플릿 클래스의 특수화에 설명 하는 형식 basic_string 형식의 요소에 따라 char16_t.

u32string

템플릿 클래스의 특수화에 설명 하는 형식 basic_string 형식의 요소에 따라 char32_t.

hd5zecz6.collapse_all(ko-kr,VS.110).gif연산자

+ 연산자

두 문자열 개체를 연결합니다.

연산자! =

연산자의 왼쪽에서 string 개체는 문자열 개체 오른쪽 인지 테스트 합니다.

연산자 = =

연산자의 왼쪽에서 string 개체는 문자열 개체 오른쪽 인지 테스트 합니다.

연산자 <

연산자의 왼쪽에 문자열 개체 보다 작을 경우 테스트 문자열 개체의 오른쪽에 있습니다.

연산자 < =

테스트 연산자의 왼쪽에 문자열 개체 오른쪽에 문자열 개체 보다 작거나입니다.

연산자 <<

문자열을 출력 스트림에 삽입 하는 템플릿 함수입니다.

연산자 >

String 개체는 연산자의 왼쪽에서 오른쪽에 문자열 개체 보다 큰 경우 테스트 합니다.

연산자 > =

String 개체는 연산자의 왼쪽에서 오른쪽에 문자열 개체 보다 크거나 인지 테스트 합니다.

연산자 >>

입력된 스트림에서 문자열을 추출 하는 템플릿 함수입니다.

hd5zecz6.collapse_all(ko-kr,VS.110).gif템플릿 함수를 특수화 된

스왑

두 문자열의 문자 배열 교환합니다.

stod

변환 된 문자 시퀀스에는double.

stof

변환 된 문자 시퀀스에는 float.

stoi

문자 시퀀스를 정수로 변환합니다.

stold

변환 된 문자 시퀀스에는 long double.

stoll

변환 된 문자 시퀀스에는 long long.

stoul

변환 된 문자 시퀀스에는 unsigned long.

stoull

변환 된 문자 시퀀스에는 unsigned long long.

to_string

값을 string으로 변환합니다.

to_wstring

값은 전체 변환 string.

hd5zecz6.collapse_all(ko-kr,VS.110).gif함수

getline

입력된 스트림에서 줄 단위로 문자열을 추출 합니다.

hd5zecz6.collapse_all(ko-kr,VS.110).gif클래스

basic_string Class

설명 하는 템플릿 클래스는 시퀀스의 임의의 문자 모양의 개체를 저장할 수 있는 개체입니다.

char_traits Struct

템플릿 클래스는 CharType 형식 문자와 관련 된 특성에 설명 합니다.

hd5zecz6.collapse_all(ko-kr,VS.110).gif특수화

char_traits<char> Struct

템플릿 구조체의 특수화 된 구조체 char_traits<CharType> 요소 형식에 char.

char_traits<wchar_t> Struct

템플릿 구조체의 특수화 된 구조체 char_traits<CharType> 요소 형식에 wchar_t.

char_traits<char16_t> Struct

템플릿 구조체의 특수화 된 구조체 char_traits<CharType> 요소 형식에 char16_t.

char_traits<char32_t> Struct

템플릿 구조체의 특수화 된 구조체 char_traits<CharType> 요소 형식에 char32_t.

요구 사항

  • 헤더: <string>

  • 네임 스페이스: std

참고 항목

참조

표준 C++ 라이브러리에서 스레드로부터의 안전성

기타 리소스

헤더 파일