I have a vector of doubles which are ordered.
std::vector<double> vec;
for(double x{0.0}; x < 10.0 + 0.5; x += 1.0) vec.push_back(x);
I am trying to use std::find_if to find the first element, and its corresponding index, of this vector for which y < element. Where y is some value.
For example, if y = 5.5 then the relevant element is element 6.0 which has index 6, and is the 7th element.
I suspect that a lambda function could be used do to this.
-
Can a lambda function be used to do this?
-
If so, how do I implement a
find_ifstatement to do what I want?
Aucun commentaire:
Enregistrer un commentaire