title: Prospective destructors in C++
body: <p>I have this code and this outputs the following:</p>
  <p>link to the following example
  <a href="https://godbolt.org/z/z8Pn9GsTv" rel="noreferrer">https://godbolt.org/z/z8Pn9GsTv</a></p>
  <pre><code>template &lt;typename T&gt;
  struct A1 {
      A1() {
          std::cout &lt;&lt; &quot;construction of a1&quot; &lt;&lt; std::endl;
      }
  
      ~A1() {
          std::cout &lt;&lt; &quot;destruction of a1&quot; &lt;&lt; std::endl;
      }
      ~A1() requires (std::is_same_v&lt;T,int&gt;) {
          std::cout &lt;&lt; &quot;it is an int&quot; &lt;&lt; std::endl;
      }
  };
  
  int main() {
      A1 &lt;int&gt;a;
      
      return 0;
  }
  </code></pre>
  <p>output:</p>
  <pre><code>construction of a1
  destruction of a1
  </code></pre>
  <p>but swapping places of destructors it gives other result:</p>
  <p>link to the code
  <a href="https://godbolt.org/z/vxj7dPqaj" rel="noreferrer">https://godbolt.org/z/vxj7dPqaj</a></p>
  <pre><code>template &lt;typename T&gt;
  struct A1 {
      A1() {
          std::cout &lt;&lt; &quot;construction of a1&quot; &lt;&lt; std::endl;
      }
  
      ~A1() requires (std::is_same_v&lt;T,int&gt;) {
          std::cout &lt;&lt; &quot;it is an int&quot; &lt;&lt; std::endl;
      }
      ~A1() {
          std::cout &lt;&lt; &quot;destruction of a1&quot; &lt;&lt; std::endl;
      }
  };
  </code></pre>
  <p>output:</p>
  <pre><code>construction of a1
  it is an int
  </code></pre>
  <p>wondering is this a bug?</p>