get index by pointer to element c++ code example
Example: get index by pointer to element of vector c++
std::vector<MyObject> vect;
MyObject *ptrX = ... // Pointer to element
ptrdiff_t index = ptrX - &vect[0];
std::vector<MyObject> vect;
MyObject *ptrX = ... // Pointer to element
ptrdiff_t index = ptrX - &vect[0];