C ++ vectors - using find (start, end, term)
3 answers
you should use std::find_first_of
:
std::string m(".!?");
end = std::find_first_of(arToken.begin() + nStart, arToken.end(), m.begin(),m.end());
+14
source to share
use the predicate and std::find_if
like this:
struct has_char {
has_char(const char *s) : str(s) {}
bool operator() (const char ch) const {
return str.find(ch) != std::string::npos;
}
private:
std::string str;
};
end = std::find_if(arToken.begin() + nStart, arToken.end(), has_char(".!?"));
+2
source to share