std::string
CXX-P2003Found using sub-string based method find
for a character look-up.
It is more efficient to use the single-character overload when searching for a single character within a std::string, because it avoids the overhead of iterating over character literal. This can be especially important if you are searching for many single characters, as the overhead can add up. This is applicable on the following std::string
search methods :-
find
rfind
find_first_of
find_first_not_of
find_last_of
find_last_not_of
std::string message("header");
message.find("a");
std::string message("header");
message.find('a');