There is no built-in function that does just that. There is std::find which is close, but since it does not return bool , it is a little more inconvenient to use.
You can always use your own to get a syntax similar to the JIa3ep clause, but without using count (which always goes through the whole sequence):
template <typename iter_t> bool contains(iter_t first, iter_t last, typename iter_t::value_type val){ return find(first, last, val) != last; }
Then you can just do this to use it:
std::vector<int> x; if (contains(x.begin(), x.end(), 4)) {...}
source share