title: Why does C++ not know to do an implicit move in the return when the variable is used in an initializer list?
body: <p>Consider <a href="https://godbolt.org/z/7aKq7v" rel="noreferrer">this</a> code:</p>
  <pre><code>#include &lt;iostream&gt;
  template&lt;typename A&gt;
  struct S{
      S(const A&amp; a){
          std::cout &lt;&lt; &quot;L\n&quot;;
      }
      S(A&amp;&amp; a){
          std::cout &lt;&lt; &quot;R\n&quot;;
      }
  };
  S&lt;int&gt; f1(){
      int a = 1;
      return {a};
  }
  S&lt;int&gt; f2(){
      int a = 1;
      return a;
  }
  S&lt;int&gt; f3(){
      int a = 1;
      return {std::move(a)};
  }
  int main()
  {
      f1();
      f2();
      f3();
  }
  </code></pre>
  <p>Output is</p>
  <blockquote>
  <p>L<br />
  R<br />
  R</p>
  </blockquote>
  <p>As you may know C++ implicitly moves in the return (in f2). When we do it manually in the initializer list it works (f3), but it is not done automagically by C++ in f1.</p>
  <p>Is there a good reason why this does not work, or is it just a corner case deemed not important enough to be specified by the standard?</p>
  <p>P.S. I know compilers can (sometimes must) do RVO, but I do not see how this could explain the output.</p>