You can use std::find
for that. Assuming you have an std::vector
full of std::strings
:
#include <algorithm> // for std::find
std::vector<std::string> v = ....;
std::vector<std::string>::const_iterator it = std::find(v.begin(), v.end(), "Key");
bool found = it != v.end();