title: bind make_shared with variadic template
body: <p>I'm trying to write the following factory class, but I can't find the proper syntax:</p>
  
  
  
  <pre class="lang-cpp prettyprint-override"><code>template&lt;class T, typename... TArgs&gt;
  class Factory {
   public:
    Factory(TArgs... args) {
      creator_ = std::bind(&amp;std::make_shared&lt;T, TArgs...&gt;, args...);
      //      ^^^ some error around here
    }
    std::shared_ptr&lt;T&gt; Create() const {
      return creator_();
    }
   private:
    std::function&lt;std::shared_ptr&lt;T&gt;()&gt; creator_;
  };
  </code></pre>
  
  <p>This is how I use the factory:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class Foo {
   public:
    Foo(bool value) {}
  };
  class Bar {
   public:
     Bar(const std::string&amp; value) {}
  };
  Factory&lt;Foo, bool&gt; f1(true);
  Factory&lt;Bar, std::string&gt; f2("string");
  </code></pre>
  
  <p>These are the errors I get when declaring <code>f1</code> and <code>f2</code>:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>error: no match for 'operator=' (operand types are 'std::function&lt;std::shared_ptr&lt;Foo&gt;()&gt;' and 'std::_Bind_helper&lt;false, std::shared_ptr&lt;Foo&gt; (*)(bool&amp;&amp;), bool&amp;&gt;::type {aka std::_Bind&lt;std::shared_ptr&lt;Foo&gt; (*(bool))(bool&amp;&amp;)&gt;}')
     creator_ = std::bind(&amp;std::make_shared&lt;T, TArgs...&gt;, args...);
              ^
  
  error: no match for 'operator=' (operand types are 'std::function&lt;std::shared_ptr&lt;Bar&gt;()&gt;' and 'std::_Bind_helper&lt;false, std::shared_ptr&lt;Bar&gt; (*)(std::basic_string&lt;char&gt;&amp;&amp;), std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;&amp;&gt;::type {aka std::_Bind&lt;std::shared_ptr&lt;Bar&gt; (*(std::basic_string&lt;char&gt;))(std::basic_string&lt;char&gt;&amp;&amp;)&gt;}')
     creator_ = std::bind(&amp;std::make_shared&lt;T, TArgs...&gt;, args...);
              ^
  </code></pre>
  
  <p>What is the correct syntax I must use with <code>std::bind</code>?</p>