title: C++ move into container
body: <p>I have a class like this:</p>
  
  <pre><code>class Object {
     ...
  }
  </code></pre>
  
  <p>and a container which essentially consists of a <code>std::vector&lt;Object&gt;</code>:</p>
  
  <pre><code>class ObjectContainer {
  public: 
      void addObject(Object ?? object);
      ...
  private:
      std::vector&lt;Object&gt; vector;
  }
  </code></pre>
  
  <p>Now after I have initialized an <code>Object</code> instance I would like to add the instance to the container and forget about i.e. something like:</p>
  
  <pre><code>Container container;
  {
      Object object(args...);
      // Maybe more object initialization
  
      container.addObject( object );
  }
  </code></pre>
  
  <p>Now - if possible I would like the container, i.e. <code>std::vector&lt;Object&gt;</code> to 'take' the current object instance without any copying - is this possible? And would the implementation of <code>Container::addObject</code> be as simple as:</p>
  
  <pre><code>void Container::addObject( Object &amp;&amp; object) {
     vector.push_back( object );
  }
  </code></pre>