title: C++ copy, move constructors
body: <p>I have code here:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;initializer_list&gt;
  
  template &lt;typename T&gt;
  class Test
  {
  public:
    Test(std::initializer_list&lt;T&gt; l)
    {
      std::cout &lt;&lt; __PRETTY_FUNCTION__ &lt;&lt; std::endl;
    }
  
    Test(const Test&lt;T&gt;&amp; copy)
    {
      std::cout &lt;&lt; __PRETTY_FUNCTION__ &lt;&lt; std::endl;
    }
    Test(Test&amp;&amp;) = delete;
    Test() = delete;
  };
  
  void f(const Test&lt;Test&lt;std::string&gt;&gt;&amp; x)
  {
    std::cout &lt;&lt; __PRETTY_FUNCTION__ &lt;&lt; std::endl;
  }
  
  void f(const Test&lt;std::string&gt;&amp; x)
  {
    std::cout &lt;&lt; __PRETTY_FUNCTION__ &lt;&lt; std::endl;
    f(Test&lt;Test&lt;std::string&gt;&gt;{x});
  }
  
  int main()
  {
    Test&lt;std::string&gt; t1 {"lol"};
    f(t1);
    return 0;
  }
  </code></pre>
  
  <p>I try to compile this with GCC 7.3.0 on my linux mint 19 with command:</p>
  
  <blockquote>
    <p>g++ -std=c++11 -O0 test.cpp -o test -Wall -pedantic</p>
  </blockquote>
  
  <p>Compilation fails with error that this call: </p>
  
  <pre><code>f(Test&lt;Test&lt;std::string&gt;&gt;{x});
  </code></pre>
  
  <p>Requires move constructor, but it's deleted. I always thought that move and copy constructors are equivalent in terms of compilation cause rvalue can be bound to const reference, but overload with explicitly defined rvalue reference is just prioritized in overload resolution. This is first time i see that compiler actually requires move constuctor and won't just use copy instead. Why? Am i missing something?</p>