title: How can I make an iterator over fields of container's items?
body: <p>So, say, I have a class that has <code>std::list&lt;std::pair&lt;int, std::string&gt;&gt;</code> inside of it; how can I implement an iterator for this class such that it iterates over strings contained in this list? </p>
  
  <p>Or, for example, in my class I have a vector of <code>struct</code>s with fields <code>a</code>, <code>b</code> and <code>c</code>; can I create an iterator (maybe inherit vector's iterator? don't know), which, when dereferenced, will return a <code>std::pair</code>, corresponding to <code>(b, c)</code>?</p>
  
  <p>By iterator I mean something like <code>std::vector</code>'s iterators: something, that I can get via <code>whatever.begin()</code> and iterate over, as mentioned, strings inside the list.</p>
  
  <p><strong>UPD</strong> Okay, here's more info on what I want. In my <code>HashMap</code> class I have <code>items</code>: a list of <code>structs</code>: each with a key, a value and a pointer to it's place in the table. What I need is an iterator; but not the one that I can get by doing <code>items.begin()</code>, since this iterator, when dereferenced, will return my struct. I need an iterator, such that I can return it when user calls <code>HashMap.begin()</code>, and it should dereference into a <code>std::pair</code>, corresponding to (key, value).</p>
  
  <p>This should, hopefully, make my question clearer.</p>
  
  <p><strong>UPD2</strong> 
  Here is my <code>struct</code>, if that helps:</p>
  
  <pre><code>template&lt;class KeyType, class ValueType&gt;
  struct node {
      KeyType key;
      ValueType value;
      node** place;
  
      node(KeyType key_ = KeyType(), ValueType value_ = ValueType()): key(key_), value(value_) {};
  };
  </code></pre>