c++ search a vector for element first seen position
问题 Solved Thank you. This is solved. Here is the solution I used. std::vector<int> v = {1,2,3,4,8,8,8,8,9,10} auto p = std::lower_bound(v.begin(),b.end(),8); int position = p - v.begin(); I want to find the first seen position of an element in a sorted vector and I want to use stl to do it. Example: v = {1,1,2,6,7,8,8,8,8,9} int position = my_fun(v.begin(),v.end(),8); // find the position of the first 8 Then position is 5. Seen this is a sorted vector, I don't want to use find(), cause it will