std::string
and std::string_view
provide functions to search for specific characters or groups of characters within a
string. If the search is successful, these functions will return the position of the first character in the string that matches the search pattern. If
the search fails, the functions will return the special value npos
.
npos
is converted to true
when used in a boolean context. Therefore, using the returned value in a boolean context to
determine if the search was successful does not work.