title: Variadic variadic template templates
body: <p>I'm currently struggling with the following code, the intent of which is to implement variadic variadic template templates:</p>
  
  <pre><code>template
  &lt;
    template &lt;typename... HeadArgs&gt; class Head,
    template &lt;typename... TailArgs&gt; class...
  &gt;
  struct join&lt;Head&lt;typename HeadArgs...&gt;, Head&lt;typename TailArgs...&gt;...&gt;
  {
    typedef Head&lt;typename HeadArgs..., typename TailArgs......&gt; result;
  };
  </code></pre>
  
  <p>Ideally, I'd be able to use this template metafunction to achieve the following:</p>
  
  <pre><code>template &lt;typename...&gt; struct obj1 {};
  template &lt;typename...&gt; struct obj2 {};
  
  typedef join
  &lt;
    obj1&lt;int, int, double&gt;, 
    obj1&lt;double, char&gt;,
    obj1&lt;char*, int, double, const char*&gt;
  &gt;::result new_obj1;
  
  typedef join
  &lt;
    obj2&lt;int, int, double&gt;, 
    obj2&lt;double, char&gt;,
    obj2&lt;char*, int, double, const char*&gt;
  &gt;::result new_obj2;
  
  /* This should result in an error, because there are 
     different encapsulating objects
  typedef join
  &lt;
    obj1&lt;int, int, double&gt;, 
    obj1&lt;double, char&gt;,
    obj2&lt;char*, int, double, const char*&gt;
  &gt;::result new_obj;
  */
  </code></pre>
  
  <p>The output of the above would hopefully create <code>new_obj1</code> and <code>new_obj2</code> in the form <code>template&lt;int, int, double, double, char, char*, int, double, const char*&gt; struct new_obj[1|2] {};</code></p>
  
  <p>I'm using gcc 4.6.2 on Windows, which outputs an "expected parameter pack before '...'" for the expansion of "<strong><code>Head&lt;typename TailArgs...&gt;</code></strong>...".</p>
  
  <p><a href="http://ideone.com/Km2ra">This error is reproducable with gcc 4.5.1</a>. </p>