std::experimental::basic_string_view - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::experimental::basic_string_view

From cppreference.com
< cpp‎ | experimental

| This library component was voted out from C++14 working paper into a separate Technical Specification. It is not a part of the draft C++14.

| This is work in progress, there may be inaccuracies.

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

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.

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>

### [edit] Template parameters

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

### [edit] 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` | `RandomAccessIterator`
`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

### [edit] Member functions

(constructor) | constructs a `basic_string_view` (public member function) [edit]
operator= | assigns a view (public member function) [edit]
##### Iterators
begincbegin | returns an iterator to the beginning (public member function) [edit]
endcend | returns an iterator to the end (public member function) [edit]
rbegincrbegin | returns a reverse iterator to the beginning (public member function) [edit]
rendcrend | returns a reverse iterator to the end (public member function) [edit]
##### Element access
operator[] | access specified character (public member function) [edit]
at | access specified character with bounds checking (public member function) [edit]
front | accesses the first character (public member function) [edit]
back | accesses the last character (public member function) [edit]
data | returns a pointer to the first character of a view (public member function) [edit]
##### Capacity
sizelength | returns the number of characters (public member function) [edit]
max_size | returns the maximum number of characters (public member function) [edit]
empty | checks whether the view is empty (public member function) [edit]
##### Modifers
clear | Clears the view (public member function) [edit]
remove_prefix | Removes characters from the start of the view (public member function) [edit]
remove_suffix | Removes characters from the end of the view (public member function) [edit]
swap | swaps the contents (public member function) [edit]
##### Operations
to_stringoperator basic_string | creates a string from the view (public member function) [edit]
copy | copies characters (public member function) [edit]
substr | returns a substring (public member function) [edit]
compare | compares two views (public member function) [edit]
find | find characters in the view (public member function) [edit]
rfind | find the last occurrence of a substring (public member function) [edit]
find_first_of | find first occurrence of characters (public member function) [edit]
find_last_of | find last occurrence of characters (public member function) [edit]
find_first_not_of | find first absence of characters (public member function) [edit]
find_last_not_of | find last absence of characters (public member function) [edit]
### Constants
npos [static] | special value. The exact meaning depends on the context (public static member constant) [edit]

### [edit] Non-member functions

operator==operator!=operator<operator>operator<=operator>= | lexicographically compares two views (function template) [edit]
##### Input/output
operator<< | performs stream output on views (function template) [edit]

### [edit] Helper classes

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

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/experimental/basic_string_view&oldid=72329"