I would be extremely grateful if somebody could tell me what as I
getting wrong with this little bit of code to find the index of a
particular element in a std::vector
std::vector<int> allVertices ;
getTriangleVertices(t[0], allVertices) ; //Fills the allVertices vector
getTriangleVertices(t[1], allVertices) ;
print("All Vertices", allVertices) ;
std::vector<int> tempSpareVertex (getUniqueElements(allVertices)) ;
print("Temp Spare Vertices", tempSpareVertex) ;
std::vector<int>::const_iterator it (std::find(allVertices.begin(),
allVertices.end(), tempSpareVertex[0]));
int index = it - allVertices.begin() ;
printf("Spare Vertex 0 Position:- %i \n", index) ;
and the debug shows things like this
All Vertices: 72 6 50 50 6 46
Temp Spare Vertices: 46 72
Spare Vertex 0 Position:- 2
which is clearly the wrong index.
Adam