20 Strings library [strings]

20.3 String classes [string.classes]

20.3.2 Class template basic_­string [basic.string]

20.3.2.7 String operations [string.ops]

20.3.2.7.2 Searching [string.find]

Let F be one of find, rfind, find_­first_­of, find_­last_­of, find_­first_­not_­of, and find_­last_­not_­of.
  • Each member function of the form
    size_type F(const basic_string& str, size_type pos) const noexcept;
    
    has effects equivalent to: return F(basic_­string_­view<charT, traits>(str), pos);
  • Each member function of the form
    size_type F(const charT* s, size_type pos) const;
    
    has effects equivalent to: return F(basic_­string_­view<charT, traits>(s), pos);
  • Each member function of the form
    size_type F(const charT* s, size_type pos, size_type n) const;
    
    has effects equivalent to: return F(basic_­string_­view<charT, traits>(s, n), pos);
  • Each member function of the form
    size_type F(charT c, size_type pos) const noexcept;
    
    has effects equivalent to:
    return F(basic_string_view<charT, traits>(addressof(c), 1), pos);
    
template<class T> size_type find(const T& t, size_type pos = 0) const noexcept(see below); template<class T> size_type rfind(const T& t, size_type pos = npos) const noexcept(see below); template<class T> size_type find_first_of(const T& t, size_type pos = 0) const noexcept(see below); template<class T> size_type find_last_of(const T& t, size_type pos = npos) const noexcept(see below); template<class T> size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept(see below); template<class T> size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept(see below);
Constraints:
  • is_­convertible_­v<const T&, basic_­string_­view<charT, traits>> is true and
  • is_­convertible_­v<const T&, const charT*> is false.
Effects: Let G be the name of the function.
Equivalent to:
basic_string_view<charT, traits> s = *this, sv = t;
return s.G(sv, pos);
Remarks: The expression inside noexcept is equivalent to is_­nothrow_­convertible_­v<const T&, basic_­string_­view<charT, traits>>.