The class template basic_string_view describes an non-owning reference to a constant contiguous sequence of char-like objects. More...
#include <string_view.h>
Public Types | |
using | const_iterator = const_pointer |
using | const_pointer = const CharT * |
using | const_reference = const CharT & |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
using | difference_type = std::ptrdiff_t |
using | iterator = const_iterator |
using | pointer = CharT * |
using | reference = CharT & |
using | reverse_iterator = const_reverse_iterator |
using | size_type = std::size_t |
using | traits_type = Traits |
using | value_type = CharT |
Public Member Functions | |
constexpr | basic_string_view () noexcept |
Default constructor. More... | |
constexpr | basic_string_view (const basic_string_view &other) noexcept |
Copy constructor. More... | |
constexpr | basic_string_view (const CharT *str) |
Constructs a view of the null-terminated character string pointed to by str , not including the terminating null character. More... | |
constexpr | basic_string_view (const CharT *str, size_type len) |
Constructs a view of the first count characters of the character array starting with the element pointed by str . More... | |
template<typename Allocator > | |
basic_string_view (const std::basic_string< CharT, Traits, Allocator > &str) noexcept | |
Constructs a view of the first str.size() characters of the character array starting with the element pointed by str.data() . More... | |
constexpr const_reference | back () const |
Returns reference to the last character in the view. More... | |
constexpr const_iterator | begin () const noexcept |
Returns an iterator to the beginning of the view. More... | |
constexpr const_iterator | cbegin () const noexcept |
Returns an iterator to the beginning of the view. More... | |
constexpr const_iterator | cend () const noexcept |
Returns an iterator to the character following the last character of the view. More... | |
constexpr int | compare (basic_string_view v) const noexcept |
The function compares the two views by calling Traits::compare(data(), v.data(), length) , where length is the small of size() and v.size() . More... | |
constexpr int | compare (const CharT *c) const noexcept |
Equivalent to compare(basic_string_view(c)) . More... | |
const_reverse_iterator | crbegin () const noexcept |
Returns a reverse iterator to the first character of the reversed view. More... | |
const_reverse_iterator | crend () const noexcept |
Returns a reverse iterator to the character following the last character of the reversed view. More... | |
constexpr const_pointer | data () const noexcept |
Returns a pointer to the underlying character array. More... | |
constexpr bool | empty () const noexcept |
Checks if the view has no characters, i.e. More... | |
constexpr const_iterator | end () const noexcept |
Returns an iterator to the character following the last character of the view. More... | |
constexpr const_reference | front () const |
Returns reference to the first character in the view. More... | |
constexpr size_type | length () const noexcept |
Returns the number of CharT elements in the view, i.e. More... | |
constexpr size_type | max_size () const noexcept |
The largest possible number of char-like objects that can be referred to by a basic_string_view. More... | |
template<typename Allocator > | |
operator std::basic_string< CharT, Traits, Allocator > () const | |
Creates a basic_string with a copy of the content of the current view. More... | |
basic_string_view & | operator= (const basic_string_view &other) noexcept |
Replaces the this view with that of other view. More... | |
constexpr const_reference | operator[] (size_type pos) const noexcept |
Returns a const reference to the character at specified location pos . More... | |
const_reverse_iterator | rbegin () const noexcept |
Returns a reverse iterator to the first character of the reversed view. More... | |
constexpr void | remove_prefix (size_type n) noexcept |
Moves the start of the view forward by n characters. More... | |
constexpr void | remove_suffix (size_type n) noexcept |
Moves the end of the view back by n characters. More... | |
const_reverse_iterator | rend () const noexcept |
Returns a reverse iterator to the character following the last character of the reversed view. More... | |
constexpr size_type | size () const noexcept |
Returns the number of CharT elements in the view, i.e. More... | |
constexpr void | swap (basic_string_view &s) noexcept |
template<typename Allocator = std::allocator<CharT>> | |
std::basic_string< CharT, Traits > | to_string (const Allocator &a=Allocator()) const |
Creates a basic_string with a copy of the content of the current view. More... | |
Static Public Attributes | |
static size_type | npos = size_type(-1) |
Detailed Description
template<typename CharT, typename Traits = std::char_traits<CharT>>
class rttr::basic_string_view< CharT, Traits >
The class template basic_string_view describes an non-owning reference to a constant contiguous sequence of char-like objects.
The purpose of this class is to avoid copying of data which is already owned somewhere else. Creating a basic_string_view will never do any heap allocation.
Member Typedef Documentation
using rttr::basic_string_view< CharT, Traits >::const_iterator = const_pointer |
using rttr::basic_string_view< CharT, Traits >::const_pointer = const CharT* |
using rttr::basic_string_view< CharT, Traits >::const_reference = const CharT& |
using rttr::basic_string_view< CharT, Traits >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
using rttr::basic_string_view< CharT, Traits >::difference_type = std::ptrdiff_t |
using rttr::basic_string_view< CharT, Traits >::iterator = const_iterator |
using rttr::basic_string_view< CharT, Traits >::pointer = CharT* |
using rttr::basic_string_view< CharT, Traits >::reference = CharT& |
using rttr::basic_string_view< CharT, Traits >::reverse_iterator = const_reverse_iterator |
using rttr::basic_string_view< CharT, Traits >::size_type = std::size_t |
using rttr::basic_string_view< CharT, Traits >::traits_type = Traits |
using rttr::basic_string_view< CharT, Traits >::value_type = CharT |
Constructor & Destructor Documentation
|
noexcept |
Default constructor.
Constructs an empty basic_string_view.
|
noexcept |
Copy constructor.
Constructs a view of the same content as other
.
constexpr rttr::basic_string_view< CharT, Traits >::basic_string_view | ( | const CharT * | str | ) |
Constructs a view of the null-terminated character string pointed to by str
, not including the terminating null character.
The length of the view is determined as if by Traits::length(str)
. The behavior is undefined if [str, str + Traits::length(str))
is not a valid range (even though the constructor may not access any of the elements of this range).
constexpr rttr::basic_string_view< CharT, Traits >::basic_string_view | ( | const CharT * | str, |
size_type | len | ||
) |
Constructs a view of the first count characters of the character array starting with the element pointed by str
.
str
can contain null characters. The behavior is undefined if [str, str + count)
is not a valid range (even though the constructor may not access any of the elements of this range).
|
noexcept |
Constructs a view of the first str.size()
characters of the character array starting with the element pointed by str.data()
.
Member Function Documentation
constexpr const_reference rttr::basic_string_view< CharT, Traits >::back | ( | ) | const |
Returns reference to the last character in the view.
- Returns
- Reference to the last character, equivalent to
operator[](size() - 1)
.
|
noexcept |
Returns an iterator to the beginning of the view.
- Returns
- const_iterator to the first character of this view.
|
noexcept |
Returns an iterator to the beginning of the view.
- Returns
- const_iterator to the first character of this view.
|
noexcept |
Returns an iterator to the character following the last character of the view.
Do not access this character, it will result in undefined behavior.
- Returns
- const_iterator to the character following the last character.
|
noexcept |
The function compares the two views by calling Traits::compare(data(), v.data(), length)
, where length
is the small of size()
and v.size()
.
- Returns
- negative value if this view is less than the other character sequence, zero if the both character sequences are equal, positive value if this view is greater than the other character sequence.
|
noexcept |
Equivalent to compare(basic_string_view(c))
.
- Returns
- negative value if this view is less than the other character sequence, zero if the both character sequences are equal, positive value if this view is greater than the other character sequence.
|
noexcept |
Returns a reverse iterator to the first character of the reversed view.
It corresponds to the last character of the non-reversed view.
- Returns
- const_reverse_iterator to the first character.
|
noexcept |
Returns a reverse iterator to the character following the last character of the reversed view.
It corresponds to the character preceding the first character of the non-reversed view. Do not access this character, it will result in undefined behavior.
- Returns
- const_reverse_iterator to the character following the last character.
|
noexcept |
Returns a pointer to the underlying character array.
The pointer is such that the range [data(); data() + size())
is valid and the values in it correspond to the values of the view.
- Remarks
- Passing data() to a function which takes a
const CharT*
may not work, because the underlying buffer may not contain a null-terminated character.
- Returns
- A pointer to the underlying character array.
|
noexcept |
Checks if the view has no characters, i.e.
whether size() == 0.
- Returns
true
if the view is empty,false
otherwise.
|
noexcept |
Returns an iterator to the character following the last character of the view.
Do not access this character, it will result in undefined behavior.
- Returns
- const_iterator to the character following the last character.
constexpr const_reference rttr::basic_string_view< CharT, Traits >::front | ( | ) | const |
Returns reference to the first character in the view.
- Returns
- Reference to the first character, equivalent to
operator[](0)
.
|
noexcept |
|
noexcept |
The largest possible number of char-like objects that can be referred to by a basic_string_view.
- Returns
- Maximum number of characters.
|
explicit |
Creates a basic_string
with a copy of the content of the current view.
- Returns
- A basic_string containing a copy of the characters of the current view.
|
noexcept |
Replaces the this view with that of other
view.
|
noexcept |
Returns a const reference to the character at specified location pos
.
No bounds checking is performed: the behavior is undefined if pos >= size()
.
- Returns
- Const reference to the requested character.
|
noexcept |
Returns a reverse iterator to the first character of the reversed view.
It corresponds to the last character of the non-reversed view.
- Returns
- const_reverse_iterator to the first character.
|
noexcept |
Moves the start of the view forward by n characters.
The behavior is undefined if n > size()
.
|
noexcept |
Moves the end of the view back by n characters.
The behavior is undefined if n > size()
.
|
noexcept |
Returns a reverse iterator to the character following the last character of the reversed view.
It corresponds to the character preceding the first character of the non-reversed view. Do not access this character, it will result in undefined behavior.
- Returns
- const_reverse_iterator to the character following the last character.
|
noexcept |
|
noexcept |
std::basic_string<CharT, Traits> rttr::basic_string_view< CharT, Traits >::to_string | ( | const Allocator & | a = Allocator() | ) | const |
Creates a basic_string
with a copy of the content of the current view.
- Returns
- A
basic_string
containing a copy of the characters of the current view.
Member Data Documentation
|
static |
The documentation for this class was generated from the following file: