title: template template member inheritance with 'using'
body: <p>The following classes implement CRTP. I would like for class <code>Derived</code> to use the constructor provided by <code>Base</code>, so I write <code>using</code>. However, I get the error message, "can only inherit constructor from direct base". Equivalently for the member variable <code>x</code>.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>
  template&lt;template&lt;typename, size_t&gt; typename G, typename F, size_t U&gt;
  struct Base
  {
      double x;
      Base(double x) : x{ x } {}
      double gimme_x()
      {
          return (*static_cast&lt;G&lt;F, U&gt;*&gt;(this)).gimme_x();
      }
  };
  
  template&lt;typename F, size_t U&gt;
  struct Derived : Base&lt;Derived, double, U&gt;
  {
      using Base&lt;Derived, double, U&gt;::Base;
      using Base&lt;Derived, double, U&gt;::x;
  
      double gimme_x()
      {
          return x + 1.8;
      }
  };
  
  </code></pre>
  
  <p>This problem can be mitigated by changing the template-template implementation of <code>Base</code> to just use a regular template.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>
  template&lt;typename G, typename F, size_t U&gt;
  struct Base
  {
      double x;
      Base(double x) : x{ x } {}
      double gimme_x()
      {
          return (*static_cast&lt;G*&gt;(this)).gimme_x();
      }
  };
  
  template&lt;typename F, size_t U&gt;
  struct Derived : Base&lt;Derived&lt;F, U&gt;, double, U&gt;
  {
      using Base&lt;Derived&lt;F, U&gt;, double, U&gt;::Base;
      using Base&lt;Derived&lt;F, U&gt;, double, U&gt;::x;
  
      double gimme_x()
      {
          return x + 1.8;
      }
  };
  
  </code></pre>
  
  <p>While the second one looks a bit more verbose, it seems like it should be equivalent to the first one in this case. What's the difference and why does the implementation of the first one fail?</p>