title: Factory class perfect forwarding
body: <p>Consider following code sample:</p>
  
  <pre><code>template&lt;class T, class U&gt;
  struct b{
      b(T &amp;&amp;, U &amp;&amp;);
      //some useful stuff
  };
  
  template&lt;class T&gt;
  struct factory{
      factory(T &amp;&amp;arg) : arg_(std::forward&lt;T&gt;(arg)){}
  
      template&lt;class U&gt;
      auto create(U &amp;&amp;u) const &amp;{
          return b&lt;const T &amp;, U&gt;(arg_, std::forward&lt;U&gt;(u));
      }
      template&lt;class U&gt;
      auto create(U &amp;&amp;u)  &amp;&amp;{
          return b&lt;T, U&gt;(std::forward&lt;T&gt;(arg_), std::forward&lt;U&gt;(u));
      }
  
      T arg_;
  };
  
  template&lt;class T&gt;
  auto
  make_factory(T &amp;&amp;t){
      return factory&lt;T&gt;(std::forward&lt;T&gt;(t));
  }
  </code></pre>
  
  <p>I am concerned with code inside <code>factory</code> struct - are the <code>create</code> methods fastest possible, is it <strong>the best</strong> way to use perfect forwarding with factory classes?</p>
  
  <ol>
  <li><p>Did I miss something or this code is 'perfect' in terms of forwarding/moving data around? I would like to avoid copying wherever it is possible.</p></li>
  <li><p>Should I add/remove const in any of the <code>create</code> methods?</p></li>
  </ol>
  
  <p>EDIT: Due to Your concerns - I am aware that sometimes I will pass lvalue reference and specialize template for it. It is desired behaviour. As I written up there - I want to avoid copying anything unless <em>really</em> needed. So factory can store reference if object was created in scope outside of it. I know it is unsafe, but still it is a design choice. For reference factory created object should also store reference. I hope this clarifies most of Your issues.</p>