std::string_view rfind() method
- od C++17
// (1) Const version only
size_type rfind( const basic_string& str, size_type pos = 0 ) const noexcept;
// (2) Const version only
size_type rfind( const CharT* s, size_type pos, size_type count ) const;
// (3) Const version only
size_type rfind( const CharT* s, size_type pos = 0 ) const;
// (4) Const version only
size_type rfind( CharT ch, size_type pos = 0 ) const noexcept;
// (5) Const version only
template < class StringViewLike >
size_type rfind( const StringViewLike& t, size_type pos = 0 ) const noexcept(/* see below */);
Finds the last substring equal to the given character sequence.
Search begins at pos, i.e. the found substring must not begin in a position following pos.
If npos or any value not smaller than size() - 1 is passed as pos, whole string will be searched.
- (1) Finds the last occurrence of
vin this view, starting at positionpos. - (2) Equivalent to
rfind(basic_string_view(std::addressof(c), 1), pos). - (3) Equivalent to
rfind(basic_string_view(s, count), pos). - (4) Equivalent to
rfind(basic_string_view(s), pos).
Parameters
v- view to search forpos- position at which to start the searchcount- length of substring to search fors- pointer to a character string to search forch- character to search for
Return value
Position of the first character of the found substring, or npos if no such substring is found.