21 Strings library [strings]

21.4 Class template basic_string [basic.string]

21.4.7 basic_string string operations [string.ops]

21.4.7.3 basic_string::rfind [string::rfind]

size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;

Effects: Determines the highest position xpos, if possible, such that both of the following conditions obtain:

  • xpos <= pos and xpos + str.size() <= size();

  • traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str.

Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.

Remarks: Uses traits::eq().

size_type rfind(const charT* s, size_type pos, size_type n) const;

Returns: rfind(basic_string(s, n), pos).

size_type rfind(const charT* s, size_type pos = npos) const;

Requires: s points to an array of at least traits::length(s) + 1 elements of charT.

Returns: rfind(basic_string(s), pos).

size_type rfind(charT c, size_type pos = npos) const noexcept;

Returns: rfind(basic_string<charT,traits,Allocator>(1,c),pos).