title: Not expected constructor called
body: <p>I'm looking into <strong>C++11</strong> move constructors but something doesn't work. In fact the issue is even  before I started writing such a constructor. Here's a code snipped:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  
  class Object {
      static std::ostream&amp; log(Object &amp;obj) {
          std::cout &lt;&lt; "Object::id = " &lt;&lt; obj.mId &lt;&lt; "::"; 
          return std::cout;
      }
  
      unsigned mId = 0;
      std::string *mText = nullptr;
  
      unsigned nextUniqueId() const {
          static unsigned id = 0;
          return ++id;
      }
  
      const std::string textInfo() const {
          std::ostringstream oss;
          oss &lt;&lt; "mText @ " &lt;&lt; &amp;mText;
          if (mText) oss &lt;&lt; " = " &lt;&lt; *mText;
  
          return oss.str();
      }
  
  public:
      Object() = delete;
      Object&amp; operator= (const Object&amp;) = delete;
  
      explicit Object(const std::string&amp; str) : mId(this-&gt;nextUniqueId()), mText(new std::string(str)) {
          Object::log(*this) &lt;&lt; "constructor::one-argument\n";
      }
  
      Object(const Object&amp; obj) : mId(this-&gt;nextUniqueId()), mText(new std::string(*obj.mText)) {
          Object::log(*this) &lt;&lt; "constructor::copy\n";
      }
  
      virtual ~Object() {
          Object::log(*this) &lt;&lt; "destructor::" &lt;&lt; this-&gt;textInfo() &lt;&lt; "\n";
          if (mText) {
              delete mText;
              mText = nullptr;
          }
      }
  };
  
  static Object get_object() {
      return Object("random text");
  }
  
  int main(int argc, char **argv) {
      Object a("first object");  // OK
  
      /*
       * Expected behaviour: inside get_object() function new Object is created which is then   copied into
       * variable b. So that new ID should be given.
       */
      Object b = get_object();  // What the hell?! Not what expected! Why?
  
      std::cout &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>The expected output is similiar to this:</p>
  
  <pre><code>Object::id = 1::constructor::one-argument    
  Object::id = 2::constructor::one-argument
  Object::id = 2::destructor::mText @ 0x7fff32c25f70 = random text
  Object::id = 3::constructor::copy
  
  Object::id = 3::destructor::mText @ &lt;DIFFERENT THAN IN ID=2&gt; = random text
  Object::id = 1::destructor::mText @ 0x7fff32c25f90 = first object
  </code></pre>
  
  <p>I get this instead:</p>
  
  <pre><code>Object::id = 1::constructor::one-argument
  Object::id = 2::constructor::one-argument
  
  Object::id = 2::destructor::mText @ 0x7fff32c25f70 = random text
  Object::id = 1::destructor::mText @ 0x7fff32c25f90 = first object
  </code></pre>
  
  <p>which looks like variable <code>b</code> is created on spot (something like <code>inline</code> maybe?). Frankly speaking I don't know what's going on, can anyone explain?</p>