title: C++ Template Specialization: compile error: "is not a type"
body: <p>If I remove the template specialization part (the one that tries to print "Test 2"), the code compiles fine, but I'd like to be able to have a special case that runs a different code path that looks clean to outside users.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  struct SpecialType {};
  
  template&lt;typename A , typename B = SpecialType&gt;
  class Test
  {
  public:
      class TestInner
      {
      public:
          TestInner&amp; operator* ();
      };
  };
  
  template&lt;typename A , typename B&gt;
  typename Test&lt;A , B&gt;::TestInner&amp; Test&lt;A , B&gt;::TestInner::operator* ()
  {
      cout &lt;&lt; "Test 1" &lt;&lt; endl;
      return *this;
  }
  
  // If the following is removed, everything compiles/works, but I want this alternate code path:
  template&lt;typename A&gt;
  typename Test&lt;A , SpecialType&gt;::TestInner&amp; Test&lt;A , SpecialType&gt;::TestInner::operator* ()
  {
      cout &lt;&lt; "Test 2" &lt;&lt; endl;
      return *this;
  }
  
  int main()
  {
      Test&lt;int , SpecialType&gt;::TestInner test;
      *test;
  
     return 0;
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Edit:
  By the way, the compiler error reads:</p>
  
  <pre><code>main.cpp:26:44: error: 'Test&lt;A, SpecialType&gt;::TestInner' is not a type
   typename Test&lt;A , SpecialType&gt;::TestInner&amp; Test&lt;A , SpecialType&gt;::TestInner::operator* ()
                                              ^
  main.cpp:26:89: error: invalid use of dependent type 'typename Test&lt;A, SpecialType&gt;::TestInner'
   typename Test&lt;A , SpecialType&gt;::TestInner&amp; Test&lt;A , SpecialType&gt;::TestInner::operator* ()
                                                                                           ^
  </code></pre>