im trying to locate the position of the minimum value in a vector, using STL find algorithm (and the min_element algorithm), but instead of returning the postion, its just givin
The short answer to what you think you asked with "How do I determine position in std::vector<>
given an iterator from it?" is the function std::distance
.
What you probably meant to do, however, was to get the value for the iterator, which you get by dereferencing it:
using namespace std;
vector::const_iterator it = min_element(v2.begin(), v2.end());
cout << "min value at position " << distance(v2.begin(), it) << " is " << *it;