title: c++ how to create iterator over one field of a struct vector
body: <p>I have a structure of all primitive types, like so:</p>
  
  <pre><code>struct record {
      int field1;
      double field2;
  }
  </code></pre>
  
  <p>I have a vector of instances of this struct, like so:</p>
  
  <pre><code>vector&lt;record&gt; records;
  </code></pre>
  
  <p>Is it possible/what is the best way to create a <code>vector&lt;int&gt;::iterator</code> that will iterate over <code>field1</code>?
  What about if I used an array <code>record records[n]</code>? I need something that looks like <code>vector&lt;int&gt;::iterator</code>.</p>
  
  <p>EDIT: I need something that IS a <code>vector&lt;int&gt;::iterator</code>.</p>