strtok es una función de C para trabajar con cadenas de caracteres (char*).
Lo que puedes hacer, es utilizar la función "find" de la librería algorithm:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
vector<string> vec = {"a", "b", "ab", "b", "c", "ab", "d", "e"};
auto tokenIterator = find(vec.begin(), vec.end(), "ab");
if(tokenIterator == vec.end()){
// No encontrado
}else{
vector<string> temp(vec.begin(), tokenIterator);
for(string& str : temp)
cout << str << endl;
}
}
http://www.cplusplus.com/reference/algorithm/find/También puedes usar "find_first_of", en caso de que tengas varios tokens.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
vector<string> vec = {"a", "b", "ab", "b", "c", "ab", "d", "e"};
vector<string> tokens = {"ab", "ac"};
auto tokenIterator = find_first_of(vec.begin(), vec.end(),
tokens.begin(), tokens.end());
if(tokenIterator == vec.end()){
// No encontrado
}else{
vector<string> temp(vec.begin(), tokenIterator);
for(string& str : temp)
cout << str << endl;
}
}
http://www.cplusplus.com/reference/algorithm/find_first_of/Como dato, en la STL de C++, todos los contenedores trabajan con iteradores, y las funciones para trabajar con iteradores, también suelen hacerlo.