#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;
int main()
{
vector<int> v = {1,2,3,4,6,4,5};
// Get index of element from iterator
int index = distance(v.begin(), find(v.begin(), v.end(), 4));
cout << index;
}
vector<int> arr = { 6, 3, 5, 2, 8 };
vector<int>::iterator itr = std::find(arr.begin(), arr.end(), elem);
if (itr != end(arr)) {
cout << "Element " << elem << " is present at index " << distance(arr, itr) << " in the given array";
}
else {
cout << "Element is not present in the given array";
}
int valueIndex = std::distance(
yourArray,
std::find(
yourArray,
yourArray + sizeof(yourArray) / sizeof(yourArray[0]),
yourValueToFind));