title: g++ c++17 class template argument deduction not working in a very specific case
body: <p>I have the following code:</p>
  
  <pre><code>template &lt;class T&gt;
  class lit {
  public:
      lit(T l) : val(l) {}
      T val;
  };
  
  template &lt;class T&gt;
  class cat {
  public:
      cat(lit&lt;T&gt; const&amp; a, lit&lt;T&gt; const&amp; b) : a(a), b(b) {}
      lit&lt;T&gt; const&amp; a;
      lit&lt;T&gt; const&amp; b;
  };
  
  template &lt;class T&gt;
  cat&lt;T&gt; operator+(lit&lt;T&gt; const&amp; a, lit&lt;T&gt; const&amp; b) {
      return cat(a, b);
  }
  
  int main() {
      auto r1 = cat((lit      ('b')),  lit('d')); // compiles
      auto r2 =     (lit      ('b')) + lit('d') ; // doesn't compile
      auto r3 =      lit      ('b')  + lit('d') ; // compiles
      auto r4 =     (lit      ('b'))            ; // compiles
      auto r5 =     (lit&lt;char&gt;('b')) + lit('d') ; // compiles
  }
  </code></pre>
  
  <p>This compiles fine with clang (as I would expect), but gcc produces the following error:</p>
  
  <pre><code>prog.cc: In function 'int main()':
  prog.cc:23:20: error: missing template arguments after 'lit'
       auto r2 =     (lit      ('b')) + lit('d') ; // doesn't compile
                      ^~~
  prog.cc:2:7: note: 'template&lt;class T&gt; class lit' declared here
   class lit : public ExpressionBuilder&lt;T&gt; {
         ^~~
  </code></pre>
  
  <p>It seems to not be able to figure out the class template deduction from the constructor only in one very specific case (<code>r2</code>). I am assuming gcc is wrong, but can someone explain why it would fail only in this very specific case?</p>
  
  <p>Example here: <a href="https://wandbox.org/permlink/jQCOhXFFQekS17Y1" rel="noreferrer">https://wandbox.org/permlink/jQCOhXFFQekS17Y1</a></p>