The find_first_of() Family
The find_first_of() methods have these prototypes:
size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept;size_type find_first_of(const charT* s, size_type pos, size_type n) const;size_type find_first_of(const charT* s, size_type pos = 0) const;size_type find_first_of(charT c, size_type pos = 0) const noexcept;
These methods work like the corresponding find() methods, except that instead of looking for a match of the entire substring, they look for the first match for any single character in the substring:
string longer("That is a funny hat.");string shorter("fluke");size_type loc1 = longer.find_first_of(shorter); // sets loc1 to 10size_type loc2 = longer.find_first_of("fat"); // ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access