title: C++ Iterators that work for both std::vector and std::map
body: <p>I need to implement something and it would be much easier if I could create, for example, an iterator that works both for <code>std::vector</code> and <code>std::map</code>. Is that possible? I'm talking about the iterators from the STL, not creating a new custom one.</p>
  <p>I have a class which stores some elements in a <code>std::vector</code>. When I return those elements sometimes through different methods, I use <code>std::vector&lt;...&gt;::iterator</code>, and this iterator is later used by other parts of the program.</p>
  <p>I want to create a new class which uses <code>std::map&lt;...&gt;</code> instead of <code>std::vector&lt;...&gt;</code>, so I can't return <code>std::vector&lt;...&gt;::iterator</code>, only <code>std::map&lt;...&gt;::iterator</code>. And no, I don't want to create an extra vector in this new class. The other parts of the program require an <code>std::vector&lt;...&gt;::iterator</code> instead of a <code>std::map&lt;...&gt;::iterator</code>.</p>