title: Returning an iterator over a template vector
body: <p>I've been searching around for something similar but couldn't find it (or what I found wasn't helpful). I'm trying to be able to have an iterator over a vector of a template class, returning it and using it outside the class, as demonstrated in the code below.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  namespace ns {
  
   template &lt;class T&gt;
   class test {
  
    private:
     vector&lt;T&gt; container;
  
    public:
     typedef vector&lt;T&gt;::iterator iterator;
  
     vector&lt;T&gt;::iterator begin() {
      return container.begin();
     }
  
     vector&lt;T&gt;::iterator end() {
      return container.end();
     }
  
   }
  
  };
  
  int main(void) {
   test&lt;int&gt; inters;
  
   for (ns::test&lt;int&gt;::iterator i = inters.begin(); i != inters.end(); i++) {
    // bla bla bla
   }
  
   cout &lt;&lt; "end" &lt;&lt; endl;
   return 0;
  }
  </code></pre>
  
  <p>(you can also check out the code here:
  <a href="http://codepad.org/RuXCYF6T" rel="noreferrer">http://codepad.org/RuXCYF6T</a>)</p>
  
  <p>I get the following error on line 15:</p>
  
  <pre><code>error: type '__gnu_debug_def::vector&lt;_Tp, std::allocator&lt;_CharT&gt; &gt;' is not derived from type 'ns::test&lt;T&gt;'
  compilation terminated due to -Wfatal-errors.
  </code></pre>
  
  <p>Thanks in advance.</p>