title: Operator overloading for C++ maps
body: <p>I need help understanding some C++ operator overload statements.  The class is declared like this: </p>
  
  <pre><code>template &lt;class key_t, class ipdc_t&gt;
  class ipdc_map_template_t : public ipdc_lockable_t
  {
      ...
      typedef map&lt;key_t,
              ipdc_t*,
              less&lt;key_t&gt;&gt; map_t;
      ...
  </code></pre>
  
  <p>The creator of the class has created an iterator for the internal map structure:</p>
  
  <pre><code>struct iterator : public map_t::iterator
  {
      iterator() {}
      iterator(const map_t::iterator &amp; it)
          : map_t::iterator(it) {}
      iterator(const iterator &amp; it)
          : map_t::iterator(
              *static_cast&lt;const map_t::iterator *&gt;(&amp;it)) {}
      operator key_t() {return ((this-&gt;operator*()).first);}           // I don't understand this.
      operator ipdc_t*() const {return ((this-&gt;operator*()).second);}  // or this.
  
  };
  </code></pre>
  
  <p>And begin() and end() return the begin() and end() of the map:</p>
  
  <pre><code>iterator begin() {IT_ASSERT(is_owner()); return map.begin();}
  iterator end() {return map.end();}
  </code></pre>
  
  <p>My question is, if I have an iterator, how do I use those overloads to get the key and the value?</p>
  
  <pre><code>ipdc_map_template_t::iterator iter;
      for( iter = my_instance.begin();
               iter != my_instance.end();
           ++iter )
      {
          key_t my_key = ??????;
          ipdc_t *my_value = ??????;
  
      }
  </code></pre>