Here are the definition found on some documentations over the net
std::string::find_first_of - find character in string.
Searches the string for the first character that matches any of the characters specified in its arguments.
std::string::npos - npos is a static member constant value with the greatest possible value for an element of type size_t.
Let's use this as an example:
Line:001. std::string sVariable = "this is a test string"`
Line:002. if(std::string::npos != sVariable.find_first_of("0123456789"))`
As you can see the std::string::find_first_of
tries to check if there are matches from the beginning of the string first(or index 0 of the string).
If there are no matches found, it then iterates to the next index of the string and and check matches on that index. And moves on to the next one.
At some point, the searching gets on to the end of the sVariable string, but is still not found. At that time, the find_first_of
will return the std::string::npos
value.
Click here for one definition of the std::string::find_first_of
.
Return Value
The position of the first character that matches.
If no matches are found, the function returns string::npos.