I read almost every thread that I found via google, but it didn't help me out..
I've got a struct inside a class:
struct animation {
int identifier;
int another_variable;
};
I store a bunch of these structs in a vector:
static std::vector<animation> anims;
Now, I need to find the index (the position) of a struct, based on the field identifier.
// This is what I found so far
int Animation::get_animation_index(int identifier) {
std::find(anims.begin(), anims.end(), identifier) - anims.begin();
}
The idea is to get the vector index anims[0] .. anims[xxx] where the struct with the identifier xx is stored.
I tried it within a loop, but then I only get access to the object itself, not the index..
for (Animation::animation a : anims) {
if (a.identifier == identifier) {
// a is now the object, but I need the vector index..
Any ideas?