tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
basic_string_view< Char, Traits > Struct Template Reference

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 Char and a size. More...

#include <etl/string_view.hpp>

Public Types

using const_iterator = Char const*
 
using const_pointer = Char const*
 
using const_reference = Char const&
 
using const_reverse_iterator = etl::reverse_iterator<const_iterator>
 
using difference_type = etl::ptrdiff_t
 
using iterator = const_iterator
 
using pointer = Char*
 
using reference = Char&
 
using reverse_iterator = const_reverse_iterator
 
using size_type = etl::size_t
 
using traits_type = Traits
 
using value_type = Char
 

Public Member Functions

constexpr basic_string_view () noexcept=default
 Default constructor. Constructs an empty basic_string_view. After construction, data() is equal to nullptr, and size() is equal to 0.
 
constexpr basic_string_view (basic_string_view const &other) noexcept=default
 Copy constructor. Constructs a view of the same content as other. After construction, data() is equal to other.data(), and size() is equal to other.size().
 
constexpr basic_string_view (Char const *str)
 Constructs a view of the null-terminated character string pointed to by s, not including the terminating null character. The length of the view is determined as if by Traits::length(s). The behavior is undefined if [s, s+Traits::length(s)) is not a valid range. After construction, data() is equal to s, and size() is equal to Traits::length(s).
 
constexpr basic_string_view (Char const *str, size_type size)
 Constructs a view of the first count characters of the character array starting with the element pointed by s. s can contain null characters. The behavior is undefined if [s, s+count) is not a valid range (even though the constructor may not access any of the elements of this range). After construction, data() is equal to s, and size() is equal to count.
 
template<typename Iter>
requires (detail::RandomAccessIterator<Iter>)
constexpr basic_string_view (Iter first, Iter last)
 Constructs a basic_string_view over the range [first, last). The behavior is undefined if [first, last) is not a valid range.
 
constexpr basic_string_view (nullptr_t)=delete
 
 ~basic_string_view () noexcept=default
 
constexpr auto back () const -> const_reference
 Returns reference to the last character in the view.
 
constexpr auto begin () const noexcept -> const_iterator
 Returns an iterator to the first character of the view.
 
constexpr auto cbegin () const noexcept -> const_iterator
 Returns an iterator to the first character of the view.
 
constexpr auto cend () const noexcept -> const_iterator
 Returns an iterator to the character following the last character of the view. This character acts as a placeholder, attempting to access it results in undefined behavior.
 
constexpr auto compare (basic_string_view v) const noexcept -> int
 Compares two character sequences.
 
constexpr auto compare (Char const *s) const -> int
 Compares two character sequences. Equivalent to compare(basic_string_view(s)).
 
constexpr auto compare (size_type pos1, size_type count1, basic_string_view v) const -> int
 Compares two character sequences. Equivalent to substr(pos1, count1).compare(v).
 
constexpr auto compare (size_type pos1, size_type count1, basic_string_view v, size_type pos2, size_type count2) const -> int
 Compares two character sequences. Equivalent to substr(pos1, count1).compare(v.substr(pos2, count2))
 
constexpr auto compare (size_type pos1, size_type count1, Char const *s) const -> int
 Compares two character sequences. Equivalent to substr(pos1, count1).compare(basic_string_view(s)).
 
constexpr auto compare (size_type pos1, size_type count1, Char const *s, size_type count2) const -> int
 Compares two character sequences. Equivalent to substr(pos1, count1).compare(basic_string_view(s, count2)).
 
constexpr auto contains (basic_string_view sv) const noexcept -> bool
 Checks if the string contains the given substring.
 
constexpr auto contains (Char c) const noexcept -> bool
 Checks if the string contains the given substring.
 
constexpr auto contains (Char const *s) const -> bool
 Checks if the string contains the given substring.
 
constexpr auto copy (Char *dest, size_type count, size_type pos=0) const -> size_type
 Copies the substring [pos, pos + rcount) to the character array pointed to by dest, where rcount is the smaller of count and size() - pos. Equivalent to Traits::copy(dest, data() + pos, rcount).
 
constexpr auto crbegin () const noexcept -> const_reverse_iterator
 Returns a reverse iterator to the first character of the reversed view. It corresponds to the last character of the non-reversed view.
 
constexpr auto crend () const noexcept -> const_reverse_iterator
 Returns a reverse iterator to the character following the last character of the reversed view.
 
constexpr auto data () const noexcept -> const_pointer
 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.
 
constexpr auto empty () const noexcept -> bool
 Checks if the view has no characters, i.e. whether size() == 0.
 
constexpr auto end () const noexcept -> const_iterator
 Returns an iterator to the character following the last character of the view. This character acts as a placeholder, attempting to access it results in undefined behavior.
 
constexpr auto ends_with (basic_string_view sv) const noexcept -> bool
 Checks if the string view ends with the given suffix, where the prefix is a string view.
 
constexpr auto ends_with (Char c) const noexcept -> bool
 Checks if the string view ends with the given suffix, where the prefix is a single character.
 
constexpr auto ends_with (Char const *str) const -> bool
 Checks if the string view ends with the given suffix, where the the prefix is a null-terminated character string.
 
constexpr auto find (basic_string_view v, size_type pos=0) const noexcept -> size_type
 Finds the first substring equal to the given character sequence. Finds the first occurence of v in this view, starting at position pos.
 
constexpr auto find (Char ch, size_type pos=0) const noexcept -> size_type
 Finds the first substring equal to the given character sequence. Equivalent to find(basic_string_view(etl::addressof(ch), 1), pos)
 
constexpr auto find (Char const *s, size_type pos, size_type count) const -> size_type
 Finds the first substring equal to the given character sequence. Equivalent to find(basic_string_view(s, count), pos)
 
constexpr auto find (Char const *s, size_type pos=0) const -> size_type
 Finds the first substring equal to the given character sequence. Equivalent to find(basic_string_view(s), pos)
 
constexpr auto find_first_not_of (basic_string_view sv, size_type pos=0) const noexcept -> size_type
 Finds the first character not equal to any of the characters in the given character sequence.
 
constexpr auto find_first_not_of (Char c, size_type pos=0) const noexcept -> size_type
 Finds the first character not equal to any of the characters in the given character sequence.
 
constexpr auto find_first_not_of (Char const *s, size_type pos, size_type count) const -> size_type
 Finds the first character not equal to any of the characters in the given character sequence.
 
constexpr auto find_first_not_of (Char const *s, size_type pos=0) const -> size_type
 Finds the first character not equal to any of the characters in the given character sequence.
 
constexpr auto find_first_of (basic_string_view v, size_type pos=0) const noexcept -> size_type
 Finds the first character equal to any of the characters in the given character sequence. Finds the first occurence of any of the characters of v in this view, starting at position pos.
 
constexpr auto find_first_of (Char c, size_type pos=0) const noexcept -> size_type
 Finds the first character equal to any of the characters in the given character sequence. Equivalent to find_first_of(basic_string_view(&c, 1), pos)
 
constexpr auto find_first_of (Char const *s, size_type pos, size_type count) const -> size_type
 Finds the first character equal to any of the characters in the given character sequence. Equivalent to find_first_of(basic_string_view(s, count), pos)
 
constexpr auto find_first_of (Char const *s, size_type pos=0) const -> size_type
 Finds the first character equal to any of the characters in the given character sequence. Equivalent to find_first_of(basic_string_view(s), pos)
 
constexpr auto find_last_not_of (basic_string_view v, size_type pos=npos) const noexcept -> size_type
 Finds the last character not equal to any of the characters of v in this view, starting at position pos.
 
constexpr auto find_last_not_of (Char c, size_type pos=npos) const noexcept -> size_type
 Finds the last character not equal to any of the characters in the given character sequence. Equivalent to find_last_not_of(basic_string_view(&c, 1), pos).
 
constexpr auto find_last_not_of (const_pointer s, size_type pos, size_type count) const -> size_type
 Finds the last character not equal to any of the characters in the given character sequence. Equivalent to find_last_not_of(basic_string_view(s, count), pos).
 
constexpr auto find_last_not_of (const_pointer s, size_type pos=npos) const -> size_type
 Finds the last character not equal to any of the characters in the given character sequence. Equivalent to find_last_not_of(basic_string_view(s), pos)
 
constexpr auto find_last_of (basic_string_view v, size_type pos=npos) const noexcept -> size_type
 Finds the last character equal to one of characters in the given character sequence. Exact search algorithm is not specified. The search considers only the interval [0; pos]. If the character is not present in the interval, npos will be returned. Finds the last occurence of any of the characters of v in this view, ending at position pos.
 
constexpr auto find_last_of (Char c, size_type pos=npos) const noexcept -> size_type
 Finds the last character equal to one of characters in the given character sequence. Exact search algorithm is not specified. The search considers only the interval [0; pos]. If the character is not present in the interval, npos will be returned. Equivalent to find_last_of(basic_string_view(&c, 1), pos).
 
constexpr auto find_last_of (Char const *s, size_type pos, size_type count) const -> size_type
 Finds the last character equal to one of characters in the given character sequence. Exact search algorithm is not specified. The search considers only the interval [0; pos]. If the character is not present in the interval, npos will be returned. Equivalent to find_last_of(basic_string_view(s, count), pos).
 
constexpr auto find_last_of (Char const *s, size_type pos=npos) const -> size_type
 Finds the last character equal to one of characters in the given character sequence. Exact search algorithm is not specified. The search considers only the interval [0; pos]. If the character is not present in the interval, npos will be returned. Equivalent to find_last_of(basic_string_view(s), pos).
 
constexpr auto front () const -> const_reference
 Returns reference to the first character in the view.
 
constexpr auto length () const noexcept -> size_type
 Returns the number of Char elements in the view, i.e. etl::distance(begin(), end()).
 
constexpr auto max_size () const noexcept -> size_type
 The largest possible number of char-like objects that can be referred to by a basic_string_view.
 
constexpr auto operator= (basic_string_view const &view) noexcept -> basic_string_view &=default
 Replaces the view with that of view.
 
constexpr auto operator[] (size_type pos) const -> const_reference
 Returns a const reference to the character at specified location pos.
 
constexpr auto rbegin () const noexcept -> const_reverse_iterator
 Returns a reverse iterator to the first character of the reversed view. It corresponds to the last character of the non-reversed view.
 
constexpr auto remove_prefix (size_type n) -> void
 Moves the start of the view forward by n characters.
 
constexpr auto remove_suffix (size_type n) -> void
 Moves the end of the view back by n characters.
 
constexpr auto rend () const noexcept -> const_reverse_iterator
 Returns a reverse iterator to the character following the last character of the reversed view.
 
constexpr auto rfind (basic_string_view sv, size_type pos=npos) const noexcept -> size_type
 Finds the last substring equal to the given character sequence. Finds the last occurence of v in this view, starting at position pos.
 
constexpr auto rfind (Char c, size_type pos=npos) const noexcept -> size_type
 Finds the last substring equal to the given character sequence. Equivalent to rfind(basic_string_view(&c, 1), pos).
 
constexpr auto rfind (Char const *s, size_type pos, size_type count) const noexcept -> size_type
 Finds the last substring equal to the given character sequence. Equivalent to rfind(basic_string_view(s, count), pos).
 
constexpr auto rfind (Char const *s, size_type pos=npos) const noexcept -> size_type
 Finds the last substring equal to the given character sequence. Equivalent to rfind(basic_string_view(s), pos).
 
constexpr auto size () const noexcept -> size_type
 Returns the number of Char elements in the view, i.e. etl::distance(begin(), end()).
 
constexpr auto starts_with (basic_string_view sv) const noexcept -> bool
 Checks if the string view begins with the given prefix, where the prefix is a string view.
 
constexpr auto starts_with (Char c) const noexcept -> bool
 Checks if the string view begins with the given prefix, where the prefix is a single character.
 
constexpr auto starts_with (Char const *str) const -> bool
 Checks if the string view begins with the given prefix, where the the prefix is a null-terminated character string.
 
constexpr auto substr (size_type pos=0, size_type count=npos) const -> basic_string_view
 Returns a view of the substring [pos, pos + rcount), where rcount is the smaller of count and size() - pos.
 
constexpr auto swap (basic_string_view &v) noexcept -> void
 Exchanges the view with that of v.
 

Static Public Attributes

static constexpr size_type npos = size_type(-1)
 This is a special value equal to the maximum value representable by the type size_type.
 

Detailed Description

template<typename Char, typename Traits = etl::char_traits<Char>>
struct etl::basic_string_view< Char, Traits >

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 Char and a size.

Member Typedef Documentation

◆ const_iterator

template<typename Char, typename Traits = etl::char_traits<Char>>
using const_iterator = Char const*

◆ const_pointer

template<typename Char, typename Traits = etl::char_traits<Char>>
using const_pointer = Char const*

◆ const_reference

template<typename Char, typename Traits = etl::char_traits<Char>>
using const_reference = Char const&

◆ const_reverse_iterator

template<typename Char, typename Traits = etl::char_traits<Char>>
using const_reverse_iterator = etl::reverse_iterator<const_iterator>

◆ difference_type

template<typename Char, typename Traits = etl::char_traits<Char>>
using difference_type = etl::ptrdiff_t

◆ iterator

template<typename Char, typename Traits = etl::char_traits<Char>>
using iterator = const_iterator

◆ pointer

template<typename Char, typename Traits = etl::char_traits<Char>>
using pointer = Char*

◆ reference

template<typename Char, typename Traits = etl::char_traits<Char>>
using reference = Char&

◆ reverse_iterator

template<typename Char, typename Traits = etl::char_traits<Char>>
using reverse_iterator = const_reverse_iterator

◆ size_type

template<typename Char, typename Traits = etl::char_traits<Char>>
using size_type = etl::size_t

◆ traits_type

template<typename Char, typename Traits = etl::char_traits<Char>>
using traits_type = Traits

◆ value_type

template<typename Char, typename Traits = etl::char_traits<Char>>
using value_type = Char

Constructor & Destructor Documentation

◆ basic_string_view() [1/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
basic_string_view ( )
constexprdefaultnoexcept

Default constructor. Constructs an empty basic_string_view. After construction, data() is equal to nullptr, and size() is equal to 0.

◆ basic_string_view() [2/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
basic_string_view ( basic_string_view< Char, Traits > const & other)
constexprdefaultnoexcept

Copy constructor. Constructs a view of the same content as other. After construction, data() is equal to other.data(), and size() is equal to other.size().

◆ basic_string_view() [3/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
basic_string_view ( Char const * str,
size_type size )
inlineconstexpr

Constructs a view of the first count characters of the character array starting with the element pointed by s. s can contain null characters. The behavior is undefined if [s, s+count) is not a valid range (even though the constructor may not access any of the elements of this range). After construction, data() is equal to s, and size() is equal to count.

◆ basic_string_view() [4/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
basic_string_view ( Char const * str)
inlineconstexpr

Constructs a view of the null-terminated character string pointed to by s, not including the terminating null character. The length of the view is determined as if by Traits::length(s). The behavior is undefined if [s, s+Traits::length(s)) is not a valid range. After construction, data() is equal to s, and size() is equal to Traits::length(s).

◆ basic_string_view() [5/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
basic_string_view ( nullptr_t )
constexprdelete

◆ basic_string_view() [6/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
template<typename Iter>
requires (detail::RandomAccessIterator<Iter>)
basic_string_view ( Iter first,
Iter last )
inlineconstexpr

Constructs a basic_string_view over the range [first, last). The behavior is undefined if [first, last) is not a valid range.

Bug
Improve SFINAE protection. See C++20 standard.

◆ ~basic_string_view()

template<typename Char, typename Traits = etl::char_traits<Char>>
~basic_string_view ( )
defaultnoexcept

Member Function Documentation

◆ back()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto back ( ) const -> const_reference
inlinenodiscardconstexpr

Returns reference to the last character in the view.

Precondition
size() > 0

◆ begin()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto begin ( ) const -> const_iterator
inlinenodiscardconstexprnoexcept

Returns an iterator to the first character of the view.

◆ cbegin()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto cbegin ( ) const -> const_iterator
inlinenodiscardconstexprnoexcept

Returns an iterator to the first character of the view.

◆ cend()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto cend ( ) const -> const_iterator
inlinenodiscardconstexprnoexcept

Returns an iterator to the character following the last character of the view. This character acts as a placeholder, attempting to access it results in undefined behavior.

◆ compare() [1/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto compare ( basic_string_view< Char, Traits > v) const -> int
inlinenodiscardconstexprnoexcept

◆ compare() [2/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto compare ( Char const * s) const -> int
inlinenodiscardconstexpr

Compares two character sequences. Equivalent to compare(basic_string_view(s)).

◆ compare() [3/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto compare ( size_type pos1,
size_type count1,
basic_string_view< Char, Traits > v ) const -> int
inlinenodiscardconstexpr

Compares two character sequences. Equivalent to substr(pos1, count1).compare(v).

◆ compare() [4/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto compare ( size_type pos1,
size_type count1,
basic_string_view< Char, Traits > v,
size_type pos2,
size_type count2 ) const -> int
inlinenodiscardconstexpr

Compares two character sequences. Equivalent to substr(pos1, count1).compare(v.substr(pos2, count2))

◆ compare() [5/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto compare ( size_type pos1,
size_type count1,
Char const * s ) const -> int
inlinenodiscardconstexpr

Compares two character sequences. Equivalent to substr(pos1, count1).compare(basic_string_view(s)).

◆ compare() [6/6]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto compare ( size_type pos1,
size_type count1,
Char const * s,
size_type count2 ) const -> int
inlinenodiscardconstexpr

Compares two character sequences. Equivalent to substr(pos1, count1).compare(basic_string_view(s, count2)).

◆ contains() [1/3]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto contains ( basic_string_view< Char, Traits > sv) const -> bool
inlinenodiscardconstexprnoexcept

Checks if the string contains the given substring.

◆ contains() [2/3]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto contains ( Char c) const -> bool
inlinenodiscardconstexprnoexcept

Checks if the string contains the given substring.

◆ contains() [3/3]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto contains ( Char const * s) const -> bool
inlinenodiscardconstexpr

Checks if the string contains the given substring.

◆ copy()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto copy ( Char * dest,
size_type count,
size_type pos = 0 ) const -> size_type
inlinenodiscardconstexpr

Copies the substring [pos, pos + rcount) to the character array pointed to by dest, where rcount is the smaller of count and size() - pos. Equivalent to Traits::copy(dest, data() + pos, rcount).

◆ crbegin()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto crbegin ( ) const -> const_reverse_iterator
inlinenodiscardconstexprnoexcept

Returns a reverse iterator to the first character of the reversed view. It corresponds to the last character of the non-reversed view.

◆ crend()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto crend ( ) const -> const_reverse_iterator
inlinenodiscardconstexprnoexcept

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. This character acts as a placeholder, attempting to access it results in undefined behavior.

◆ data()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto data ( ) const -> const_pointer
inlinenodiscardconstexprnoexcept

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.

◆ empty()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto empty ( ) const -> bool
inlinenodiscardconstexprnoexcept

Checks if the view has no characters, i.e. whether size() == 0.

◆ end()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto end ( ) const -> const_iterator
inlinenodiscardconstexprnoexcept

Returns an iterator to the character following the last character of the view. This character acts as a placeholder, attempting to access it results in undefined behavior.

◆ ends_with() [1/3]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto ends_with ( basic_string_view< Char, Traits > sv) const -> bool
inlinenodiscardconstexprnoexcept

Checks if the string view ends with the given suffix, where the prefix is a string view.

Effectively returns size() >= sv.size() && compare(size() - sv.size(), npos, sv) == 0

◆ ends_with() [2/3]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto ends_with ( Char c) const -> bool
inlinenodiscardconstexprnoexcept

Checks if the string view ends with the given suffix, where the prefix is a single character.

Effectively returns !empty() && Traits::eq(back(), c)

◆ ends_with() [3/3]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto ends_with ( Char const * str) const -> bool
inlineconstexpr

Checks if the string view ends with the given suffix, where the the prefix is a null-terminated character string.

Effectively returns ends_with(basic_string_view(s))

◆ find() [1/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find ( basic_string_view< Char, Traits > v,
size_type pos = 0 ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the first substring equal to the given character sequence. Finds the first occurence of v in this view, starting at position pos.

Returns
Position of the first character of the found substring, or npos if no such substring is found.

◆ find() [2/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find ( Char ch,
size_type pos = 0 ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the first substring equal to the given character sequence. Equivalent to find(basic_string_view(etl::addressof(ch), 1), pos)

Returns
Position of the first character of the found substring, or npos if no such substring is found.

◆ find() [3/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find ( Char const * s,
size_type pos,
size_type count ) const -> size_type
inlineconstexpr

Finds the first substring equal to the given character sequence. Equivalent to find(basic_string_view(s, count), pos)

Returns
Position of the first character of the found substring, or npos if no such substring is found.

◆ find() [4/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find ( Char const * s,
size_type pos = 0 ) const -> size_type
inlineconstexpr

Finds the first substring equal to the given character sequence. Equivalent to find(basic_string_view(s), pos)

Returns
Position of the first character of the found substring, or npos if no such substring is found.

◆ find_first_not_of() [1/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_first_not_of ( basic_string_view< Char, Traits > sv,
size_type pos = 0 ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the first character not equal to any of the characters in the given character sequence.

Returns
Position of the first character not equal to any of the characters in the given string, or npos if no such character is found.

◆ find_first_not_of() [2/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_first_not_of ( Char c,
size_type pos = 0 ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the first character not equal to any of the characters in the given character sequence.

Returns
Position of the first character not equal to any of the characters in the given string, or npos if no such character is found.

◆ find_first_not_of() [3/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_first_not_of ( Char const * s,
size_type pos,
size_type count ) const -> size_type
inlinenodiscardconstexpr

Finds the first character not equal to any of the characters in the given character sequence.

Returns
Position of the first character not equal to any of the characters in the given string, or npos if no such character is found.

◆ find_first_not_of() [4/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_first_not_of ( Char const * s,
size_type pos = 0 ) const -> size_type
inlinenodiscardconstexpr

Finds the first character not equal to any of the characters in the given character sequence.

Returns
Position of the first character not equal to any of the characters in the given string, or npos if no such character is found.

◆ find_first_of() [1/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_first_of ( basic_string_view< Char, Traits > v,
size_type pos = 0 ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the first character equal to any of the characters in the given character sequence. Finds the first occurence of any of the characters of v in this view, starting at position pos.

Returns
Position of the first occurrence of any character of the substring, or npos if no such character is found.

◆ find_first_of() [2/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_first_of ( Char c,
size_type pos = 0 ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the first character equal to any of the characters in the given character sequence. Equivalent to find_first_of(basic_string_view(&c, 1), pos)

Returns
Position of the first occurrence of any character of the substring, or npos if no such character is found.

◆ find_first_of() [3/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_first_of ( Char const * s,
size_type pos,
size_type count ) const -> size_type
inlineconstexpr

Finds the first character equal to any of the characters in the given character sequence. Equivalent to find_first_of(basic_string_view(s, count), pos)

Returns
Position of the first occurrence of any character of the substring, or npos if no such character is found.

◆ find_first_of() [4/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_first_of ( Char const * s,
size_type pos = 0 ) const -> size_type
inlineconstexpr

Finds the first character equal to any of the characters in the given character sequence. Equivalent to find_first_of(basic_string_view(s), pos)

Returns
Position of the first occurrence of any character of the substring, or npos if no such character is found.

◆ find_last_not_of() [1/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_last_not_of ( basic_string_view< Char, Traits > v,
size_type pos = npos ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the last character not equal to any of the characters of v in this view, starting at position pos.

Returns
Position of the last character not equal to any of the characters in the given string, or npos if no such character is found.

◆ find_last_not_of() [2/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_last_not_of ( Char c,
size_type pos = npos ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the last character not equal to any of the characters in the given character sequence. Equivalent to find_last_not_of(basic_string_view(&c, 1), pos).

Returns
Position of the last character not equal to any of the characters in the given string, or npos if no such character is found.

◆ find_last_not_of() [3/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_last_not_of ( const_pointer s,
size_type pos,
size_type count ) const -> size_type
inlinenodiscardconstexpr

Finds the last character not equal to any of the characters in the given character sequence. Equivalent to find_last_not_of(basic_string_view(s, count), pos).

Returns
Position of the last character not equal to any of the characters in the given string, or npos if no such character is found.

◆ find_last_not_of() [4/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_last_not_of ( const_pointer s,
size_type pos = npos ) const -> size_type
inlinenodiscardconstexpr

Finds the last character not equal to any of the characters in the given character sequence. Equivalent to find_last_not_of(basic_string_view(s), pos)

Returns
Position of the last character not equal to any of the characters in the given string, or npos if no such character is found.

◆ find_last_of() [1/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_last_of ( basic_string_view< Char, Traits > v,
size_type pos = npos ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the last character equal to one of characters in the given character sequence. Exact search algorithm is not specified. The search considers only the interval [0; pos]. If the character is not present in the interval, npos will be returned. Finds the last occurence of any of the characters of v in this view, ending at position pos.

Returns
Position of the last occurrence of any character of the substring, or npos if no such character is found.

◆ find_last_of() [2/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_last_of ( Char c,
size_type pos = npos ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the last character equal to one of characters in the given character sequence. Exact search algorithm is not specified. The search considers only the interval [0; pos]. If the character is not present in the interval, npos will be returned. Equivalent to find_last_of(basic_string_view(&c, 1), pos).

Returns
Position of the last occurrence of any character of the substring, or npos if no such character is found.

◆ find_last_of() [3/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_last_of ( Char const * s,
size_type pos,
size_type count ) const -> size_type
inlineconstexpr

Finds the last character equal to one of characters in the given character sequence. Exact search algorithm is not specified. The search considers only the interval [0; pos]. If the character is not present in the interval, npos will be returned. Equivalent to find_last_of(basic_string_view(s, count), pos).

Returns
Position of the last occurrence of any character of the substring, or npos if no such character is found.

◆ find_last_of() [4/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto find_last_of ( Char const * s,
size_type pos = npos ) const -> size_type
inlineconstexpr

Finds the last character equal to one of characters in the given character sequence. Exact search algorithm is not specified. The search considers only the interval [0; pos]. If the character is not present in the interval, npos will be returned. Equivalent to find_last_of(basic_string_view(s), pos).

Returns
Position of the last occurrence of any character of the substring, or npos if no such character is found.

◆ front()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto front ( ) const -> const_reference
inlinenodiscardconstexpr

Returns reference to the first character in the view.

Precondition
size() > 0

◆ length()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto length ( ) const -> size_type
inlinenodiscardconstexprnoexcept

Returns the number of Char elements in the view, i.e. etl::distance(begin(), end()).

◆ max_size()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto max_size ( ) const -> size_type
inlinenodiscardconstexprnoexcept

The largest possible number of char-like objects that can be referred to by a basic_string_view.

◆ operator=()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto operator= ( basic_string_view< Char, Traits > const & view) -> basic_string_view &=default
constexprdefaultnoexcept

Replaces the view with that of view.

◆ operator[]()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto operator[] ( size_type pos) const -> const_reference
inlinenodiscardconstexpr

Returns a const reference to the character at specified location pos.

Precondition
pos < size()

◆ rbegin()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto rbegin ( ) const -> const_reverse_iterator
inlinenodiscardconstexprnoexcept

Returns a reverse iterator to the first character of the reversed view. It corresponds to the last character of the non-reversed view.

◆ remove_prefix()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto remove_prefix ( size_type n) -> void
inlineconstexpr

Moves the start of the view forward by n characters.

Precondition
n <= size()

◆ remove_suffix()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto remove_suffix ( size_type n) -> void
inlineconstexpr

Moves the end of the view back by n characters.

Precondition
n <= size()

◆ rend()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto rend ( ) const -> const_reverse_iterator
inlinenodiscardconstexprnoexcept

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. This character acts as a placeholder, attempting to access it results in undefined behavior.

◆ rfind() [1/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto rfind ( basic_string_view< Char, Traits > sv,
size_type pos = npos ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the last substring equal to the given character sequence. Finds the last occurence of v in this view, starting at position pos.

Returns
Position of the first character of the found substring or npos if no such substring is found.

◆ rfind() [2/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto rfind ( Char c,
size_type pos = npos ) const -> size_type
inlinenodiscardconstexprnoexcept

Finds the last substring equal to the given character sequence. Equivalent to rfind(basic_string_view(&c, 1), pos).

Returns
Position of the first character of the found substring or npos if no such substring is found.

◆ rfind() [3/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto rfind ( Char const * s,
size_type pos,
size_type count ) const -> size_type
inlineconstexprnoexcept

Finds the last substring equal to the given character sequence. Equivalent to rfind(basic_string_view(s, count), pos).

Returns
Position of the first character of the found substring or npos if no such substring is found.

◆ rfind() [4/4]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto rfind ( Char const * s,
size_type pos = npos ) const -> size_type
inlineconstexprnoexcept

Finds the last substring equal to the given character sequence. Equivalent to rfind(basic_string_view(s), pos).

Returns
Position of the first character of the found substring or npos if no such substring is found.

◆ size()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto size ( ) const -> size_type
inlinenodiscardconstexprnoexcept

Returns the number of Char elements in the view, i.e. etl::distance(begin(), end()).

◆ starts_with() [1/3]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto starts_with ( basic_string_view< Char, Traits > sv) const -> bool
inlinenodiscardconstexprnoexcept

Checks if the string view begins with the given prefix, where the prefix is a string view.

Effectively returns substr(0, sv.size()) == sv

◆ starts_with() [2/3]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto starts_with ( Char c) const -> bool
inlinenodiscardconstexprnoexcept

Checks if the string view begins with the given prefix, where the prefix is a single character.

Effectively returns !empty() && Traits::eq(front(), c)

◆ starts_with() [3/3]

template<typename Char, typename Traits = etl::char_traits<Char>>
auto starts_with ( Char const * str) const -> bool
inlinenodiscardconstexpr

Checks if the string view begins with the given prefix, where the the prefix is a null-terminated character string.

Effectively returns starts_with(basic_string_view(s))

◆ substr()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto substr ( size_type pos = 0,
size_type count = npos ) const -> basic_string_view
inlinenodiscardconstexpr

Returns a view of the substring [pos, pos + rcount), where rcount is the smaller of count and size() - pos.

◆ swap()

template<typename Char, typename Traits = etl::char_traits<Char>>
auto swap ( basic_string_view< Char, Traits > & v) -> void
inlineconstexprnoexcept

Exchanges the view with that of v.

Member Data Documentation

◆ npos

template<typename Char, typename Traits = etl::char_traits<Char>>
size_type npos = size_type(-1)
staticconstexpr

This is a special value equal to the maximum value representable by the type size_type.

The exact meaning depends on context, but it is generally used either as end of view indicator by the functions that expect a view index or as the error indicator by the functions that return a view index.


The documentation for this struct was generated from the following file: