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
Public Member Functions
str
, not including the terminating null character. More... str
. More... str.size()
characters of the character array starting with the element pointed by str.data()
. More... Traits::compare(data(), v.data(), length)
, where length
is the small of size()
and v.size()
. More... Static Public Attributes
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
Constructor & Destructor Documentation
Default constructor.
Constructs an empty basic_string_view.
Copy constructor.
Constructs a view of the same content as other
.
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).
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).
Constructs a view of the first str.size()
characters of the character array starting with the element pointed by str.data()
.
Member Function Documentation
Returns reference to the last character in the view.
- Returns
- Reference to the last character, equivalent to
operator[](size() - 1)
.
Returns an iterator to the beginning of the view.
- Returns
- const_iterator to the first character of this view.
Returns an iterator to the beginning of the view.
- Returns
- const_iterator to the first character of this view.
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.
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.
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.
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.
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.
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.
Checks if the view has no characters, i.e.
whether size() == 0.
- Returns
true
if the view is empty,false
otherwise.
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.
Returns reference to the first character in the view.
- Returns
- Reference to the first character, equivalent to
operator[](0)
.
The largest possible number of char-like objects that can be referred to by a basic_string_view.
- Returns
- Maximum number of characters.
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.
Replaces the this view with that of other
view.
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.
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.
Moves the start of the view forward by n characters.
The behavior is undefined if n > size()
.
Moves the end of the view back by n characters.
The behavior is undefined if n > size()
.
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.
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
The documentation for this class was generated from the following file: