All I want to do is to check whether an element exists in the vector or not, so I can deal with each case.
if ( item_present )
do_this();
else
do_that();
c++stdstdvector
All I want to do is to check whether an element exists in the vector or not, so I can deal with each case.
if ( item_present )
do_this();
else
do_that();
Best Answer
You can use
std::find
from<algorithm>
:This returns an iterator to the first element found. If not present, it returns an iterator to one-past-the-end. With your example: