title: Initializing a std::map iterator class member
body: <p>I'm trying to do this:</p>
  
  <pre><code>typedef std::map&lt;std::string, time_t&gt; my_map;
  const mymap&amp; some_function();
  
  class bla
  {
  private:
    my_map::iterator current
    bla(const mymap&amp; m) : current(m.begin())
    {   }
  }
  </code></pre>
  
  <p>And it's not working. The somewhat more convoluted real error message is:</p>
  
  <blockquote>
    <p>error: no matching function for call to 'std::_Rb_tree_iterator, long int> >::_Rb_tree_iterator(std::map, long int>::const_iterator)'</p>
  </blockquote>
  
  <p>I tried moving the initialization/assignment to the constructor body:</p>
  
  <pre><code>{ current = m.begin(); }
  </code></pre>
  
  <p>Which didn't work either. So I thought, the type of <code>current</code> is wrong, so I just let the compiler deduce that:</p>
  
  <pre><code>...
     decltype(my_map::begin()) current;
  ...
  </code></pre>
  
  <p>Which doesn't work either.</p>
  
  <p>All I need is an iterator member that is set at <code>bla</code> construction time, so I don't have to explicitly set it in some stupid extra function and can iterate over the map externally through:</p>
  
  <pre><code>bool bla::do_stuff(...output...)
  { 
      if(current = m.end())
          return false;
      balblabla(current);
      ++current;
      return true;
  }
  </code></pre>