title: What is the purpose of the declaration "template auto A::f(int t) -> decltype(t + g())"
body: <p><a href="http://eel.is/c++draft/expr.prim#this-2" rel="nofollow noreferrer">expr.prim.this</a>:</p>
  
  <blockquote>
    <p>If a declaration declares a member function or member function
    template of a class X, the expression this is a prvalue of type
    “pointer to cv-qualifier-seq X” between the optional cv-qualifier-seq
    and the end of the function-definition, member-declarator, or
    declarator. It shall not appear before the optional cv-qualifier-seq
    and it shall not appear within the declaration of a static member
    function (although its type and value category are defined within a
    static member function as they are within a non-static member
    function). [ Note: This is because declaration matching does not occur
    until the complete declarator is known. — end note ] [ Note: In a
    trailing-return-type, the class being defined is not required to be
    complete for purposes of class member access. Class members declared
    later are not visible. </p>
    
    <p>Example:</p>
  
  <pre><code>struct A {
    char g();
    template&lt;class T&gt; auto f(T t) -&gt; decltype(t + g())
      { return t + g(); }
  };
  template auto A::f(int t) -&gt; decltype(t + g());
  </code></pre>
  </blockquote>
  
  <p>I don't know much about templates, but in the example that follows I didn't have to use this declaration to instantiate the member template function <code>A::f</code></p>
  
  <pre><code>#include&lt;iostream&gt;
  #include &lt;iomanip&gt;
  
  struct A {
      char g();
      template&lt;class T&gt; auto f(T t) -&gt; decltype(t + g())
      { return t + g(); }
  };
  
  char A::g() { return 'a'; }
  
  struct C {
      operator float() { return 1; }
  };
  
  int main()
  {
      A a;
      std::cout &lt;&lt; std::fixed;
      std::cout &lt;&lt; std::setprecision(2);
      std::cout &lt;&lt; a.f(1) &lt;&lt; '\n';
      std::cout &lt;&lt; a.f(1.0) &lt;&lt; '\n';
      std::cout &lt;&lt; a.f(C{}) &lt;&lt; '\n';
  } 
  </code></pre>
  
  <p>which prints</p>
  
  <pre><code>98
  98.00
  98.00
  </code></pre>