This is in a piece of C++ code I am looking through at the moment but I have never seen it before. Can someone tell me what it means? Is it just setting the bool to true if the searchText is found?
size_t startPos = searchString.find("searchText");
bool found = startPos != std::string::npos;
std::string::find()returns the position of the searched substring in the given string orstd::string::npos(a constant) if the substring is not found.Perhaps you would read the code better if it had been written that way:
That is, if
startPosis different fromstd::string::nposthen the substring was found.