So I was looking for a way to search a string in a list of strings. I have coded the following
bool contains(const std::list<std::string>& data, const std::string& str)
{
std::list<std::string>::iterator i;
for(i=data.begin(); i!=data.end(); ++i)
{
if (str == *i)
return true;
}
return false;
}
This is just a very basic code. I m aware of the find method but it takes in the start and end . Ideal solution would be taking entire container. There are some boost methods for the same , however I m not sure how to use them. can you give some example for boost find for generic searching of element.
Use Boost.Range: