이름공간
변수
행위

std::basic_string

cppreference.com
< cpp‎ | string
 
 
 
std::basic_string
 
<string> 에 정의되어 있음.
template<

    class CharT,
    class Traits = std::char_traits<CharT>,
    class Allocator = std::allocator<CharT>

> class basic_string;

basic_string 클래스 템플릿은 char 또는 이와 유사한 객체의 시퀀스를 저장하고 조작합니다. 이 클래스는 문자 자료형이나 그것의 연산에 관한 성질에 의존적이지 않습니다. 대신에 이러한 연산의 정의는 Traits 템플릿 매개변수로부터 주어지는데, 이는 특수화된 std::char_traits이거나 이와 호환되는 traits 클래스입니다.

The elements of a basic_string are stored contiguously, that is, for a basic_string s, &*(s.begin() + n) == &*s.begin() + n for any n in [0, s.size()), or, equivalently, a pointer to s[0] can be passed to functions that expect a pointer to the first element of a CharT[] array.

(since C++11)

공통 문자 타입을 위한 몇몇 자료형이 정의되어 있으며, 아래와 같습니다.

<string> 헤더에 정의됨.
자료형 정의
std::string std::basic_string<char>
std::wstring std::basic_string<wchar_t>
std::u16string (C++11) std::basic_string<char16_t>
std::u32string (C++11) std::basic_string<char32_t>

목차

[편집] 템플릿 매개변수

CharT - 문자 타입
Traits - 문자 타입에 대한 연산을 정의하는 traits 클래스
Allocator - 내부 저장소를 할당하기 위한 Allocator 타입

[편집] 멤버 자료형

멤버 자료형 정의
traits_type Traits
value_type Traits::char_type
allocator_type 할당자 [edit]
size_type 부호 없는 정수(unsigned int) 타입 (일반적으로 std::size_t) [edit]
difference_type 부호 있는 정수(signed int) 타입 (보통 std::ptrdiff_t) [edit]
reference Allocator::reference (until C++11)
value_type& (since C++11) [edit]
const_reference Allocator::const_reference (until C++11)
const value_type& (since C++11) [edit]
pointer Allocator::pointer (until C++11)
std::allocator_traits<Allocator>::pointer (since C++11) [edit]
const_pointer Allocator::const_pointer (until C++11)
std::allocator_traits<Allocator>::const_pointer (since C++11) [edit]
iterator RandomAccessIterator [edit]
const_iterator 상수(constant) 양방향 반복자(iterator) [edit]
reverse_iterator std::reverse_iterator<iterator> [edit]
const_reverse_iterator std::reverse_iterator<const_iterator> [edit]

[편집] Member functions

constructs a basic_string
(public member function) [edit]
assigns values to the string
(public member function) [edit]
assign characters to a string
(public member function) [edit]
returns the associated allocator
(public member function) [edit]
Element access
access specified character with bounds checking
(public member function) [edit]
access specified character
(public member function) [edit]
(C++11)
accesses the first character
(public member function) [edit]
(C++11)
accesses the last character
(public member function) [edit]
returns a pointer to the first character of a string
(public member function) [edit]
returns a non-modifiable standard C character array version of the string
(public member function) [edit]
Iterators
returns an iterator to the beginning
(public member function) [edit]

(C++11)
returns an iterator to the end
(public member function) [edit]
returns a reverse iterator to the beginning
(public member function) [edit]
returns a reverse iterator to the end
(public member function) [edit]
Capacity
checks whether the string is empty
(public member function) [edit]
returns the number of characters
(public member function) [edit]
returns the maximum number of characters
(public member function) [edit]
reserves storage
(public member function) [edit]
returns the number of characters that can be held in currently allocated storage
(public member function) [edit]
reduces memory usage by freeing unused memory
(public member function) [edit]
Operations
clears the contents
(public member function) [edit]
inserts characters
(public member function) [edit]
removes characters
(public member function) [edit]
appends a character to the end
(public member function) [edit]
(C++11)
removes the last character
(public member function) [edit]
appends characters to the end
(public member function) [edit]
appends characters to the end
(public member function) [edit]
compares two strings
(public member function) [edit]
replaces specified portion of a string
(public member function) [edit]
returns a substring
(public member function) [edit]
copies characters
(public member function) [edit]
changes the number of characters stored
(public member function) [edit]
swaps the contents
(public member function) [edit]
Search
find characters in the string
(public member function) [edit]
find the last occurrence of a substring
(public member function) [edit]
find first occurrence of characters
(public member function) [edit]
find first absence of characters
(public member function) [edit]
find last occurrence of characters
(public member function) [edit]
find last absence of characters
(public member function) [edit]

Constants

[static]
special value. The exact meaning depends on the context
(public static member constant) [edit]

[편집] Non-member functions

두 문자열 또는 문자열과 문자를 이어붙입니다
(function template) [edit]
두 문자열을 사전순으로 비교합니다
(function template) [edit]
std::swap 알고리즘을 특수화합니다
(function template) [edit]
Input/output
문자열에 대한 스트림 입력 및 출력을 수행합니다
(function template) [edit]
입·출력 스트림으로부터 문자열로 데이터를 읽어들입니다
(function) [edit]
Numeric conversions
(C++11)
(C++11)
(C++11)
문자열을 부호 있는 정수로 변환합니다
(function) [edit]
(C++11)
(C++11)
문자열을 부호 없는 정수로 변환합니다
(function) [edit]
(C++11)
(C++11)
(C++11)
문자열을 부동소숫점 값으로 변환합니다
(function) [edit]
(C++11)
정수 또는 부동소숫점 값을 string으로 변환합니다
(function) [edit]
정수 또는 부동소숫점 값을 wstring으로 변환합니다
(function) [edit]

[편집] Literals

Defined in namespace std::literals::string_literals
널 문자 종결 문자열로부터 basic_string을 반환합니다
(function) [edit]

[편집] Helper classes

hash support for strings
(class template specialization) [edit]