이름공간
변수
행위

std::basic_string_view

cppreference.com
< cpp‎ | string

틀:cpp/string/basic string view/navbar

<string_view> 에 정의되어 있음.
template<

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

>class basic_string_view;
(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_viewstd::basic_string_view<char>
std::wstring_viewstd::basic_string_view<wchar_t>
std::u16string_viewstd::basic_string_view<char16_t>
std::u32string_viewstd::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_typeTraits
value_typeCharT
pointerCharT*
const_pointerconst CharT*
referenceCharT&
const_referenceconst CharT&
const_iterator implementation-defined constant RandomAccessIterator and ContiguousIterator whose value_type is CharT
iteratorconst_iterator
reverse_iteratorconst_reverse_iterator
const_reverse_iteratorstd::reverse_iterator<const_iterator>
size_typestd::size_t
difference_typestd::ptrdiff_t

Note: iterator and const_iterator are the same type because string views are views into constant character sequences.

[편집]Member functions

틀:cpp/string/basic string view/dsc constructor틀:cpp/string/basic string view/dsc operator=틀:cpp/string/basic string view/dsc begin틀:cpp/string/basic string view/dsc end틀:cpp/string/basic string view/dsc rbegin틀:cpp/string/basic string view/dsc rend틀:cpp/string/basic string view/dsc operator at틀:cpp/string/basic string view/dsc at틀:cpp/string/basic string view/dsc front틀:cpp/string/basic string view/dsc back틀:cpp/string/basic string view/dsc data틀:cpp/string/basic string view/dsc size틀:cpp/string/basic string view/dsc max size틀:cpp/string/basic string view/dsc empty틀:cpp/string/basic string view/dsc remove prefix틀:cpp/string/basic string view/dsc remove suffix틀:cpp/string/basic string view/dsc swap틀:cpp/string/basic string view/dsc copy틀:cpp/string/basic string view/dsc substr틀:cpp/string/basic string view/dsc compare틀:cpp/string/basic string view/dsc starts with틀:cpp/string/basic string view/dsc ends with틀:cpp/string/basic string view/dsc find틀:cpp/string/basic string view/dsc rfind틀:cpp/string/basic string view/dsc find first of틀:cpp/string/basic string view/dsc find last of틀:cpp/string/basic string view/dsc find first not of틀:cpp/string/basic string view/dsc find last not of틀:cpp/string/basic string view/dsc npos
Iterators
Element access
Capacity
Modifiers
Operations

Constants

[편집]Non-member functions

틀:cpp/string/basic string view/dsc operator cmp틀:cpp/string/basic string view/dsc operator ltlt
Input/output

[편집]Literals

틀:cpp/string/basic string view/dsc operator""sv
Defined in namespace std::literals::string_view_literals

[편집]Helper classes

문자열 보기(string views)를 위한 해시 지원
(class template specialization)[edit]

[편집]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
close