std::basic_string_view
cppreference.com
틀:cpp/string/basic string view/navbar
<string_view> 에 정의되어 있음. | ||
template< class CharT, | (since C++17) | |
The class template basic_string_view
describes an object that can refer to a constant contiguous sequence of char-like objects with the first element of the sequence at position zero.
보통 CharT
상수에 대한 포인터와 크기, 이 두 인자를 받도록 구현한다.
자주 사용되는 문자형 타입에 맞는 정의들을 사용할 수 있다.:
<string_view> 헤더에 정의됨. | |
Type | Definition |
std::string_view | std::basic_string_view<char> |
std::wstring_view | std::basic_string_view<wchar_t> |
std::u16string_view | std::basic_string_view<char16_t> |
std::u32string_view | std::basic_string_view<char32_t> |
목차 |
[편집]템플릿 인자
CharT | - | character type |
Traits | - | CharTraits class specifying the operations on the character type. Like for basic_string , Traits::char_type must name the same type as CharT or the behavior is undefined. |
[편집]Member types
Member type | Definition |
traits_type | Traits |
value_type | CharT |
pointer | CharT* |
const_pointer | const CharT* |
reference | CharT& |
const_reference | const CharT& |
const_iterator | implementation-defined constant RandomAccessIterator and ContiguousIterator whose value_type is CharT |
iterator | const_iterator |
reverse_iterator | const_reverse_iterator |
const_reverse_iterator | std::reverse_iterator<const_iterator> |
size_type | std::size_t |
difference_type | std::ptrdiff_t |
Note: iterator
and const_iterator
are the same type because string views are views into constant character sequences.
[편집]Member functions
[편집]Non-member functions
Input/output |
[편집]Literals
Defined in namespace std::literals::string_view_literals |
[편집]Helper classes
문자열 보기(string views)를 위한 해시 지원 (class template specialization) |
[편집]Notes
It is the programmer's responsibility to ensure that std::string_view
does not outlive the pointed-to character array:
std::string_view good("a string literal");// OK: "good" points to a static array std::string_view bad("a temporary string"s);// "bad" holds a dangling pointer