I would like to implement a function similar to the math function from excel, that is, given a vector and a value in the vector, return the relative position of that value in that container.

However, my code

```
vector<double> vec;
double x = 25.0;
int pos = 0;
for (int i = 0; i!=vec.size(); ++i) {
if (x == vec[i])
pos = i;
}
return pos;
```

is not as efficient as i wanted to be. What are more efficient ways to implement this simple function?

Thank you.