title: C++ typedef with nested templates is not a class, struct, or union type
body: <p>I'm not sure to understand why the following code is not compiled with g++:</p>
  
  <pre><code>t.cpp: In instantiation of ‘Distrib&lt;double&gt;’:
  t.cpp:28:56:   instantiated from ‘Sampler&lt;Distrib&lt;Solution&lt;double&gt; &gt; &gt;’
  t.cpp:35:48:   instantiated from here
  t.cpp:16:45: erreur: ‘double’ is not a class, struct, or union type
  t.cpp:18:43: erreur: ‘double’ is not a class, struct, or union type
  </code></pre>
  
  <p>I was expecting to be able to propagate the <code>AtomType</code> type across the nested templates…</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  template&lt;typename T&gt;
  class Solution
  {
      public:
          typedef T AtomType;
  };
  
  template&lt;typename SOLT&gt;
  class Distrib
  {
      public:
          typedef typename SOLT::AtomType AtomType;
          typedef std::vector&lt;AtomType&gt; Matrix;
  
          Matrix matrix;
  };
  
  template&lt;typename DT&gt;
  class Sampler
  {
      public:
          typedef typename DT::AtomType AtomType;
          typedef typename Distrib&lt;AtomType&gt;::Matrix Matrix;
  
          Matrix matrix;
  };
  
  int main()
  {
      Sampler&lt; Distrib&lt; Solution&lt;double&gt; &gt; &gt; sampler;
  }
  </code></pre>