title: Friend declaration of literal operator in class template
body: <p>I'm trying to make a class that can only be constructed through a literal operator, but it fails to build on gcc.</p>
  
  <p>Here's a stripped down example:</p>
  
  <pre><code>#include &lt;cstddef&gt;
  
  template&lt;typename C&gt;
  class Foo;
  Foo&lt;char&gt; operator "" _foo(const char*, std::size_t);
  
  template&lt;typename C&gt;
  class Foo
  {
      Foo() = default;
      friend Foo&lt;char&gt; operator "" _foo(const char*, std::size_t);
  };
  
  Foo&lt;char&gt; operator "" _foo(const char* str, std::size_t size)
  {
      return Foo&lt;char&gt;();
  }
  
  int main()
  {
      auto foo = "Foo"_foo;
      return 0;
  }
  </code></pre>
  
  <p>It fails with this message: <a href="https://godbolt.org/z/kfcNMR" rel="nofollow noreferrer">https://godbolt.org/z/kfcNMR</a></p>
  
  <pre><code>&lt;source&gt;:11:22: error: 'Foo&lt;char&gt; operator""_foo(const char*, std::size_t)' has invalid argument list
  </code></pre>
  
  <p>It works on clang and msvc, and without the template it works on gcc: <a href="https://godbolt.org/z/exfm5Q" rel="nofollow noreferrer">https://godbolt.org/z/exfm5Q</a></p>
  
  <p>Is this a compiler bug or am I making a mistake?</p>