title: C++ template function with vector
body: <p>I have the following lines of code and compilation errors. It should be my wrong understanding of the template function, or c++ generics, or something else. Thanks in advance for pointing it out. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  template &lt;typename T&gt;
  T* find(vector&lt;T&gt; &amp;vec, T value)
  {
    vector&lt;T&gt;::iterator first = vec.begin();
    vector&lt;T&gt;::iterator last = vec.end();
    for(; first != last; first ++)
        if(*first == value)
            return first;
    return 0;
  }
  </code></pre>
  
  <p>The compile errors in console</p>
  
  <pre><code>debug.cpp: In function ‘T* find(std::vector&lt;T, std::allocator&lt;_CharT&gt; &gt;&amp;, T)’:
  debug.cpp:9: error: expected `;' before ‘first’
  debug.cpp:10: error: expected `;' before ‘last’
  debug.cpp:11: error: ‘first’ was not declared in this scope
  debug.cpp:11: error: ‘last’ was not declared in this scope
  </code></pre>