title: Combing two factory methods returning unique_ptr and shared_ptr into one in C++?
body: <p>Lets assume I have two factory functions, one returning <code>std::unique_ptr</code> and the other returning <code>std::shared_ptr</code>:</p>
  
  <pre><code>template&lt;class T, class... Args&gt;
  std::shared_ptr&lt;T&gt; createObjectS (Args... args)
  {
    // running some code
    return std::make_shared&lt;T&gt;(args...);
  }
  template&lt;class T, class... Args&gt;
  std::unique_ptr&lt;T&gt; createObjectU (Args... args)
  {
    // running some code
    return std::make_unique&lt;T&gt;(args...);
  }
  </code></pre>
  
  <p>Is it possible to combine these two functions into one using template meta programming?</p>