title: How can I safely overload custom deleter of std::unique_ptr?
body: <p>I am trying to reduce code duplication while using <code>std::unique_ptr</code> and it's custom deleter.</p>
  <p>I have the some containers <code>Foo</code>, <code>Bar</code> which are allocated using <em>one</em> custom allocator, so cannot be freed with <code>delete</code>.</p>
  <p>So the current code is:</p>
  <pre><code>struct UniqueFooDeleter
  {
     void operator()(Foo* foo) 
     {
        internal_free(foo);
     }
  };
  using unique_foo_ptr = std::unique_ptr&lt;Foo, UniqueFooDeleter&gt;;
  
  struct UniqueBarDeleter 
  {
     void operator()(Bar* bar) 
     {
        internal_free(bar);
     }
  };
  using unique_bar_ptr = std::unique_ptr&lt;Bar, UniqueBarDeleter&gt;;
  </code></pre>
  <p>I changed it to:</p>
  <pre><code>struct UniqueInternalDeleter
  {
     void operator()(Bar* bar)
     {
        internal_free(bar);
     }
  
     void operator()(Foo* foo)
     {
        internal_free(foo);
     }
  };
  using unique_bar_ptr = std::unique_ptr&lt;Bar, UniqueInternalDeleter&gt;;
  using unique_foo_ptr = std::unique_ptr&lt;Foo, UniqueInternalDeleter&gt;;
  </code></pre>
  <p>How can I do better such that any number of containers that are allocated via <code>internal_free</code> can be used as <code>std::unique_ptr</code>s ?</p>