title: C++ Template in constructor
body: <p>I have this weird issue where my c++ codes failed to build; it was able to build before but i am puzzled why i am facing this issue now;</p>
  <blockquote>
  <p>error: C2065: 'T': undeclared identifier</p>
  </blockquote>
  <p>at this line in the class constructor.</p>
  <p><code>Diagnostic(int* pointer, std::function&lt;QVariant(int*)&gt; fn = [](int* pointer){return QVariant::fromValue(std::remove_pointer_t&lt;T&gt;(pointer)) ;})</code></p>
  <pre class="lang-cpp prettyprint-override"><code>template&lt;typename T&gt;
  class Diagnostic : QObject
  {
      using T3 = std::remove_pointer_t&lt;T&gt;;
  public:
  
      Diagnostic(int* pointer, std::function&lt;QVariant(int*)&gt; fn = [](int* pointer){return QVariant::fromValue(std::remove_pointer_t&lt;T&gt;(pointer));} )
      {
      }
  
  };
  
  
  int main(int argc, char *argv[])
  {
      int * test = new int;
      *test=5;
      Diagnostic&lt;int*&gt; dg(test);
      delete test;
  }
  </code></pre>
  <p>However if the code below is ok</p>
  <pre class="lang-cpp prettyprint-override"><code>template&lt;typename T&gt;
  class Diagnostic : QObject
  {
      using T3 = std::remove_pointer_t&lt;T&gt;;
  public:
  
      Diagnostic(int* pointer)
      {
          std::function&lt;QVariant(int*)&gt; fn = [](int* pointer){return QVariant::fromValue(std::remove_pointer_t&lt;T&gt;(pointer)) ;};
      }
  
  };
  </code></pre>
  <p>But the second one is not what i want, as i need to pass the function
  std::function&lt;QVariant(int*)&gt; fn into a base class during class instantiation.
  Any help is appreciated. I don't know why there is such error when previously i can build the codes.</p>