title: Template method to select between functions based on accessibility of constructor
body: <p>I am writing a class <code>ptr_scope_manager</code> to manage the creation and destruction of pointers in a given scope. I have studied the answers from this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/11425576/private-constructor-inhibits-use-of-emplace-back-to-avoid-a-move">Private constructor inhibits use of emplace[_back]() to avoid a move</a></p>
  
  <p>And it appears that if I want to manage the creation of an object whose class has a <em>private</em> constructor, my internal <code>std::vector</code> can use <code>push_back</code> but not <code>emplace_back</code> to construct the object. This is because <code>emplace_back</code> uses an internal class to construct the object. That means friending the <code>ptr_scope_manager</code> is not sufficient to allow it to create objects with private constructors.</p>
  
  <p>So what I have done is make two <code>create</code> methods, one for objects with public constructors and one for objects with private constructors that have friended the <code>ptr_scope_manager</code>.</p>
  
  <pre><code>template&lt;typename Type&gt;
  class ptr_scope_manager
  {
  private:
      std::vector&lt;Type&gt; ptrs;
  
  public:
      template&lt;typename... Args&gt;
      Type* create_private(Args... args)
      {
          ptrs.push_back(Type(args...));
          return &amp;ptrs.back();
      }
  
      template&lt;typename... Args&gt;
      Type* create_public(Args... args)
      {
          ptrs.emplace_back(args...);
          return &amp;ptrs.back();
      }
  };
  
  class public_ctor
  {
      int i;
  public:
      public_ctor(int i): i(i) {} // public
  };
  
  class private_ctor
  {
      friend class ptr_scope_manager&lt;private_ctor&gt;;
      int i;
  private:
      private_ctor(int i): i(i) {} // private
  };
  
  int main()
  {
      ptr_scope_manager&lt;public_ctor&gt; public_manager;
      ptr_scope_manager&lt;private_ctor&gt; private_manager;
  
      public_manager.create_public(3);
      public_manager.create_private(3);
  
  //  private_manager.create_public(3); // compile error
      private_manager.create_private(3);
  }
  </code></pre>
  
  <p><strong>My question is this:</strong></p>
  
  <p>Is there any way I can use SFINAE (or otherwise?) to automatically select between <code>create_public()</code> and <code>create_private()</code> based on whether or not the template <code>Type</code> parameter has a public or private constructor? Perhaps utilizing <code>std::is_constructible</code>?</p>
  
  <p>It would be nice to have only one <code>create()</code> method that auto-selects the more efficient <code>create_public()</code> method where possible and falling back on the slightly less efficient <code>create_private</code> when necessary. </p>