title: Should I still return const objects in C++11?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12051012/should-i-return-const-objects">Should I return const objects?</a><br>
    (The original title of that question was: <strong>int foo() or const int foo()?</strong> explaining why I missed it.)</p>
  </blockquote>
  
  <hr>
  
  <p>Effective C++, Item 3: Use const whenever possible. In particular, returning const objects is promoted to avoid unintended assignment like <code>if (a*b = c) {</code>. I find it a little paranoid, nevertheless I have been following this advice.</p>
  
  <p>It seems to me that returning const objects can degrade performance in C++11.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  using namespace std;
  
  class C {
  public:
      C() : v(nullptr) { }
  
      C&amp; operator=(const C&amp; other) {
          cout &lt;&lt; "copy" &lt;&lt; endl;
          // copy contents of v[]
          return *this;
      }
  
      C&amp; operator=(C&amp;&amp; other) {
          cout &lt;&lt; "move" &lt;&lt; endl;
          v = other.v, other.v = nullptr;
          return *this;
      }
  
  private:
      int* v;
  };
  
  const C const_is_returned() { return C(); }
  
  C nonconst_is_returned() { return C(); }
  
  int main(int argc, char* argv[]) {
      C c;
      c = const_is_returned();
      c = nonconst_is_returned();
      return 0;
  }
  </code></pre>
  
  <p>This prints:</p>
  
  <pre><code>copy
  move
  </code></pre>
  
  <p>Do I implement the move assignment correctly? Or I simply shouldn't return const objects anymore in C++11?</p>