std::experimental::basic_string_view (3) - Linux Manuals

std::experimental::basic_string_view: std::experimental::basic_string_view

NAME

std::experimental::basic_string_view - std::experimental::basic_string_view

Synopsis


Defined in header <experimental/string_view>
template<
class CharT, (library fundamentals TS)
class Traits = std::char_traits<CharT>
> class basic_string_view;


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.
A typical implementation holds only two members: a pointer to constant CharT and a size.
Several typedefs for common character types are provided:


Defined in header <experimental/string_view>
Type Definition
std::experimental::string_view std::experimental::basic_string_view<char>
std::experimental::wstring_view std::experimental::basic_string_view<wchar_t>
std::experimental::u16string_view std::experimental::basic_string_view<char16_t>
std::experimental::u32string_view std::experimental::basic_string_view<char32_t>

Template parameters


CharT - character type
Traits - traits class specifying the operations on the character type

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 LegacyRandomAccessIterator
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


                      constructs a basic_string_view
constructor (public member function)
                      assigns a view
operator= (public member function)

Iterators


                      returns an iterator to the beginning
begin (public member function)
cbegin
                      returns an iterator to the end
end (public member function)
cend
                      returns a reverse iterator to the beginning
rbegin (public member function)
crbegin
                      returns a reverse iterator to the end
rend (public member function)
crend

Element access


                      access specified character
operator[] (public member function)
                      access specified character with bounds checking
at (public member function)
                      accesses the first character
front (public member function)
                      accesses the last character
back (public member function)
                      returns a pointer to the first character of a view
data (public member function)

Capacity


                      returns the number of characters
size (public member function)
length
                      returns the maximum number of characters
max_size (public member function)
                      checks whether the view is empty
empty (public member function)

Modifiers


                      Shrinks the view by moving its start forward
remove_prefix (public member function)
                      Shrinks the view by moving its end backward
remove_suffix (public member function)
                      swaps the contents
swap (public member function)

Operations


                      creates a string from the view
to_string (public member function)
operator_basic_string
                      copies characters
copy (public member function)
                      returns a substring
substr (public member function)
                      compares two views
compare (public member function)
                      find characters in the view
find (public member function)
                      find the last occurrence of a substring
rfind (public member function)
                      find first occurrence of characters
find_first_of (public member function)
                      find last occurrence of characters
find_last_of (public member function)
                      find first absence of characters
find_first_not_of (public member function)
                      find last absence of characters
find_last_not_of (public member function)

Constants


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

Non-member functions


operator==
operator!= lexicographically compares two views
operator< (function template)
operator>
operator<=
operator>=

Input/output


           performs stream output on views
operator<< (function template)

Helper classes


std::hash<std::experimental::string_view> hash support for views
std::hash<std::experimental::wstring_view> (class template specialization)
std::hash<std::experimental::u16string_view>
std::hash<std::experimental::u32string_view>


Feature test macros


                                   a value of at least 201411 indicates that basic_string_view template is supported
__cpp_lib_experimental_string_view (macro constant)