title: compiler ignores explicitly-defined move constructor?
body: <p>I'm trying to understand why the following code doesn't call my move-constructor. I compiled using gnu++11.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class Foo{
    int value;
    public:
    Foo(int v){ value = v; }
    Foo(const Foo&amp; g){ 
      value = g.value; 
      std::cout &lt;&lt; "copy construct called\n"; 
    }
    Foo(Foo&amp;&amp; g){ 
      value = g.value; 
      std::cout &lt;&lt; "move construct called\n"; 
    }
    int getValue() const{ return value; }
  };
  
  Foo operator+(const Foo&amp; f, const Foo&amp; g){
    Foo h(f.getValue() + g.getValue());
    return h;
  }
  
  void sayValue(const Foo&amp; f){
    std::cout &lt;&lt; f.getValue() &lt;&lt; std::endl;
  }
  
  int main(){
    Foo f(5);
    sayValue(f + f);
    return 0;
  } 
  </code></pre>
  
  <p>Running the following code simply prints <code>10</code> instead of</p>
  
  <pre><code>move construct called
  10
  </code></pre>
  
  <p>as I expect. The reason I expect that is because when I define the + binary operator for Foo's, returning Foo g should invoke the move constructor, if I understand correctly.</p>
  
  <p>Is this because the compiler is simply optimizing by ignoring my move constructor define, or is it because one of my assumptions is flawed?</p>