title: Can template partial specialization narrow the argument type in C++?
body: <p>In the next program, struct template <code>A&lt;int&gt;</code> has a specialization <code>A&lt;char&gt;</code>:</p>
  <pre><code>template &lt;int&gt;
  struct A { constexpr operator int() { return 1; } };
  
  template &lt;char c&gt;
  struct A&lt;c&gt; { constexpr operator int() { return 2; } };
  
  int main() {
      static_assert( A&lt;1000&gt;{} == 1 ); //ok in Clang and GCC
      static_assert( A&lt;1&gt;{} == 2 ); //ok in Clang only
  }
  </code></pre>
  <ul>
  <li>Clang accepts the whole program.</li>
  <li>GCC accepts the specialization definition, but ignores it in <code>A&lt;1&gt;{}</code>.</li>
  <li>MSVC complains on such specialization:</li>
  </ul>
  <pre><code>error C2753: 'A&lt;c&gt;': partial specialization cannot match argument list for primary template
  </code></pre>
  <p>Demo: <a href="https://gcc.godbolt.org/z/Ef95jv5E5" rel="noreferrer">https://gcc.godbolt.org/z/Ef95jv5E5</a></p>
  <p>Which compiler is right here?</p>