title: Type alias / using declaration for iterator in C++11
body: <p>I am having trouble getting a using declaration to work that I believe should work:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  template&lt;typename C, typename V&gt;
  vector&lt;typename C::iterator&gt; find_all1(C&amp; c, V v)
  {
    vector&lt;typename C::iterator&gt; res;
    for (auto p = c.begin(); p!=c.end(); ++p) {
      if (*p == v)
        res.push_back(p);
    }
    return res;
  }
  
  template&lt;typename T&gt;
  using Iterator&lt;T&gt; = typename T::iterator;
  
  template &lt;typename C, typename V&gt;
  vector&lt;Iterator&lt;C&gt;&gt; find_all2(C&amp; c, V v)
  {
    vector&lt;Iterator&lt;C&gt;&gt; res;
    for (auto p = c.begin(); p != c.end(); ++p) {
      if (*p == v)
        res.push_back(p);
    }
    return res;
  }
  
  int main(int argc, const char *argv[])
  {
    return 0;
  }
  </code></pre>
  
  <p>This is basically an example from Stroustrup's book, and it won't compile. The first piece (find_all1) does, but the version of the template that tries to employ the using declaration won't.</p>
  
  <p>The leading portion of the error spew looks like this:</p>
  
  <pre><code>$ make
  c++  -g -fPIC -std=c++0x -stdlib=libc++  -c -o iter_tests2.o iter_tests2.cpp
  iter_tests2.cpp:18:7: error: no template named 'Iterator'; did you mean 'iterator'?
  using Iterator&lt;T&gt; = typename T::iterator;
        ^~~~~~~~
        iterator
  /usr/bin/../lib/c++/v1/iterator:415:25: note: 'iterator' declared here
  struct _LIBCPP_TYPE_VIS iterator
                          ^
  iter_tests2.cpp:18:15: error: partial specialization of alias templates is not permitted
  using Iterator&lt;T&gt; = typename T::iterator;
                ^~~
  </code></pre>
  
  <p>There's more, but I think the important part is about the using declaration.</p>