title: No type named 'type' in CTRP derived class
body: <p>I've been experimenting with the <a href="https://en.wikipedia.org/wiki/Curiously_recurring_template_patternhttp://" rel="noreferrer">Curiously Recurring Template Pattern</a> for a generic single-argument functor and have two implementations: one using a template template parameter which works and a second where I try to access the derived Functor::type in the interface class. In the latter example, the compiler (gcc 5.4.0) reports </p>
  
  <blockquote>
    <p><strong>error</strong>: no type named '<strong>type</strong>' in 'struct Cube&lt; double >'</p>
  </blockquote>
  
  <pre><code>template&lt;class T, template&lt;class&gt; class Functor&gt;
  class FunctorInterface_1 {
  private:
    const Functor&lt;T&gt; &amp;f_cref;
  public:
    FunctorInterface_1() : f_cref(static_cast&lt;const Functor&lt;T&gt;&amp;&gt;(*this)) {}
    T operator() ( T val ) const { return f_cref(val); }
  }; // FunctorInterface_1 (works)
  
  template&lt;class Functor&gt;
  class FunctorInterface_2 {
  private:
    const Functor &amp;f_cref;
  public:
    using Ftype = typename Functor::type;
    FunctorInterface_2() : f_cref(static_cast&lt;const Functor&amp;&gt;(*this)) {}
    Ftype operator() ( Ftype val ) const { return f_cref(val); }
  }; // FunctorInterface_2 (no type in Functor!)
  </code></pre>
  
  <p>I then try to compile with T=double in main() of the following two classes:</p>
  
  <pre><code>template&lt;class T&gt; 
  struct Square : public FunctorInterface_1&lt;T,Square&gt; {
    T operator()( T val ) const { return val*val; }
  }; // Square
  
  
  template&lt;class T&gt;
  struct Cube : public FunctorInterface_2&lt;Cube&lt;T&gt;&gt; {
    using type = T; 
    T operator() ( T val ) const { return val*val*val; }
  }; // Cube
  </code></pre>
  
  <p>Can the FunctorInterface_2/Cube example be modified to work, or 
  is it necessary for the interface class to be templated on T as 
  in the first example? Thanks!</p>
  
  <p>EDIT: Using gcc -std=c++14, I can get the second example to compile and run
  by using auto return and argument types in FunctorInterface_1::operator(), however, as I understand, auto argument types are not part of the C++14 standard. </p>
  
  <p>EDIT 2: Well I feel a bit thick. I just realized that I could template FunctorInterface_1::operator() on a new parameter, however, for the application I have in mind, I would really like my base class to be able to access types defined in the derived class. </p>