myślę szukasz std::any_of
, która zwróci true/false odpowiedź wykryć, czy element jest w pojemniku (array, wektorowe, deque, etc.)
int val = SOME_VALUE; // this is the value you are searching for
bool exists = std::any_of(std::begin(myArray), std::end(myArray), [&](int i)
{
return i == val;
});
Jeśli chcesz wiem, gdzie jest element, std::find
zwróci iterator do pierwszego elementu pasującego do podanych kryteriów (lub predykatu, który je podasz).
int val = SOME_VALUE;
int* pVal = std::find(std::begin(myArray), std::end(myArray), val);
if (pVal == std::end(myArray))
{
// not found
}
else
{
// found
}
Spójrz na przykład na [ 'std :: find'] (http://www.cplusplus.com/reference/algorithm/find/). – DCoder