You can use std::find from
#include
#include
vector
//can have other data types instead of int but must same datatype as item
std::find(vec.begin(), vec.end(), item) != vec.end()
This returns a bool (true if present, false otherwise). With your example:
#include
#include
if ( std::find(vec.begin(), vec.end(), item) != vec.end() )
do_this();
else
do_that();
As others have said, use the STL find or find_if functions. But if you are searching in very large vectors and this impacts performance, you may want to sort your vector and then use the binary_search, lower_bound, or upper_bound algorithms.