title: Why does iterator type deduction fail?
body: <p>Why does this not work in C++?<br>
  Why can't I restrict <code>foo</code>'s parameter to <code>std::vector&lt;T&gt;::iterator</code> like this, and what is the best workaround?</p>
  
  <pre><code>#include &lt;vector&gt;
  
  template&lt;class T&gt;
  void foo(typename std::vector&lt;T&gt;::iterator) { }
  
  int main()
  {
      std::vector&lt;int&gt; v;
      foo(v.end());
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>In function ‘int main()’:
       error: no matching function for call to ‘foo(std::vector&lt;int&gt;::iterator)’
       note: candidate is:
      note: template&lt;class T&gt; void foo(typename std::vector&lt;T&gt;::iterator)
      note:   template argument deduction/substitution failed:
       note:   couldn’t deduce template parameter ‘T’
  </code></pre>