title: Define a static constexpr member of same type of a template class
body: <p><a href="https://stackoverflow.com/questions/70356275/working-around-limitation-of-constexpr-static-data-member-with-same-type-as-en">A similar question of non-templated class</a></p>
  <p>For a template class,</p>
  <pre><code>template &lt;typename T&gt;
  struct Test {
      T data;
  
      static const Test constant;
  };
  </code></pre>
  <p>it's fine when defining a <code>static constexpr</code> member variable of specialized type:<br/></p>
  <pre><code>template &lt;&gt;
  inline constexpr Test&lt;int&gt; Test&lt;int&gt;::constant {42};
  </code></pre>
  <p><a href="https://godbolt.org/z/o4c4YojMf" rel="nofollow noreferrer">https://godbolt.org/z/o4c4YojMf</a></p>
  <hr />
  <p>While results are diverged by compilers when defining a <code>static constexpr</code> member directly from a template class without instantiation:<br/></p>
  <pre><code>template &lt;typename T&gt;
  inline constexpr Test&lt;T&gt; Test&lt;T&gt;::constant {42};
  </code></pre>
  <p><a href="https://godbolt.org/z/M8jdx3WzM" rel="nofollow noreferrer">https://godbolt.org/z/M8jdx3WzM</a></p>
  <p><code>GCC</code> compiles.<br/>
  <code>clang</code> ignores the <code>constexpr</code> specifier in definition.<br/>
  <code>MSVC</code>... <code>/std:c++17</code> works well, but <code>/std:c++20</code> rejects due to redefinition.</p>
  <hr />
  <p>I have learnt that <a href="https://eel.is/c++draft/dcl.constexpr#1.sentence-1" rel="nofollow noreferrer"><code>constexpr</code> can be applied to the definition a variable or variable template</a></p>
  <p>And in this example, which one is right? Why?</p>