trying to find an info on what happens if an empty vector used during std::find but didn't had much luck finding any info.
My question is, if an empty vector passed to std::find, is the return value always a nullptr or is it undefined behaviour?
std::vector<int> someDataContainer; auto it = std::find(someDataContainer.begin(), someDataContainer.end(), 1);
The return value of
find when the element is not present is the
[alg.find] (emphasis mine):
Let E be:
*i == valuefor
Returns: The first iterator
iin the range
[first, last)for which E is
lastif no such iterator is found.
This includes the element not being present because the range is empty.