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