Finding if all elements in a vector<string> are in a string

Posted by devin on Stack Overflow See other posts from Stack Overflow or by devin
Published on 2010-04-21T03:16:20Z Indexed on 2010/04/21 3:23 UTC
Read the original article Hit count: 233

Filed under:
|

I have a vector and I need to see if all the strings in that vector are substrings of another given string.

eg

vector<string> v;
v.push_back("str1");
v.push_back("str2");
string s1 = "str1, str2, str3";
string s2 = "str1, str3";

Is there a way to get true from s1 and false from s2 without looping over the vector? Also, note that due to my environment, I can't use boost. I think if I had boost, I could do this.

© Stack Overflow or respective owner

Related posts about c++

Related posts about vector