[ Web Proxy ]
URL:
Viewing: https://ko.cppreference.com/cpp/string/basic_string_view [Back]  [Original]

std::basic_string_view - cppreference.com
cppreference.com

std::basic_string_view

cppreference.com

:cpp/string/basic string view/navbar

<tbody> </tbody>
<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_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

: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

Web Proxy Viewer  |  New URL  |  Original Page