title: Passing rvalue reference to const lvalue reference paremeter
body: <p>I am trying to understand C++11 <em>rvalue references</em> and how to use them for optimal performance in my code.</p>
  
  <p>Let's say we have a class <code>A</code> that has a member pointer to a large amount of dynamically allocated data.</p>
  
  <p>Furthermore, a method <code>foo(const A&amp; a)</code> that does something with an object of class <code>A</code>.</p>
  
  <p>I want to <strong>prevent the copy constructor of <code>A</code> from being called</strong> when an object of <code>A</code> is passed to the function <code>foo</code>, since in that case it will perform a deep copy of the underlying heap data.</p>
  
  <p>I tested passing an lvalue reference:</p>
  
  <pre><code>    A a;
      foo(a);
  </code></pre>
  
  <p>and passing an rvalue reference:</p>
  
  <pre><code>    foo(A());
  </code></pre>
  
  <p>In both cases the copy constructor was <em>not</em> called.</p>
  
  <p>Is this expected or is this due to some optimization of my compiler (Apple LLVM 5.1)? Is there any specification about this?</p>