title: c++11 foreach syntax and custom iterator
body: <p>I am writing an iterator for a container which is being used in place of a STL container. Currently the STL container is being used in many places with the <a href="http://en.cppreference.com/w/cpp/language/range-for" rel="noreferrer">c++11 foreach syntax</a> eg: <code>for(auto &amp;x: C)</code>. We have needed to update the code to use a custom class that wraps the STL container:</p>
  
  <pre><code>template&lt; typename Type&gt;
  class SomeSortedContainer{
      std::vector&lt;typename Type&gt; m_data; //we wish to iterate over this
      //container implementation code
  };    
  class SomeSortedContainerIterator{
      //iterator code
  };
  </code></pre>
  
  <p>How do I get auto to use the correct iterator for the custom container so the code is able to be called in the following way?:</p>
  
  <pre><code>SomeSortedContainer C;
  for(auto &amp;x : C){
      //do something with x... 
  }
  </code></pre>
  
  <p>In general what is required to ensure that auto uses the correct iterator for a class?</p>