title: Syntax of final, override, const with trailing return types
body: <p>I'm trying to override a virtual but also use the keywords <code>override</code>, <code>final</code> and <code>const</code>, with trailing return type. The problem seems to be in the derived class, and the compiler error (saying that I did not specify the trailing return type) is not too helpful. The code is here: <a href="https://wandbox.org/permlink/zh3hD4Ukgrg6txyE" rel="nofollow noreferrer">https://wandbox.org/permlink/zh3hD4Ukgrg6txyE</a></p>
  
  <p>And also pasted below. I've played around with different ordering but still can't seem to get it correct. Any help would be appreciated, thank you.</p>
  
  <pre><code>#include&lt;iostream&gt;
  using std::cout; using std::endl; using std::ostream;
  //////////////////////////////////////////////
  //Base stuff
  class Base
  {
  public:
    Base(int i=2):bval(i){}
    virtual ~Base()=default;
    virtual auto debug(ostream&amp; os=cout)const-&gt;ostream&amp;;
  
  private:
    int bval=0;
  };
  
  auto Base::debug(ostream&amp; os) const-&gt;ostream&amp;
  {
    os &lt;&lt; "bval: " &lt;&lt; bval &lt;&lt; endl;
    return os;
  }
  
  ///////////////////////////////////////////////
  //Derived stuff
  class Derived : public Base
  {
  public:
    Derived(int i=2,int j=3):Base(i), dval(j){}
    ~Derived()=default;
  
    auto debug(ostream&amp; os=cout) const override final-&gt;ostream&amp;; // error here
  
  private:
    int dval=0;
  };
  
  auto Derived::debug(ostream&amp; os) const override final-&gt;ostream&amp;
  {
    os &lt;&lt; "dval: " &lt;&lt; dval &lt;&lt; endl;
    return os;
  }
  
  ///////////////////////////////////////////////
  //Testing!
  int main()
  {
    Base b(42);
    b.debug()&lt;&lt;endl;
    return 0;
  }
  </code></pre>