title: Deleter type in unique_ptr vs. shared_ptr
body: <p>I thought it is very curious when I discovered that the standard defines <code>std::unique_ptr</code> and <code>std::shared_ptr</code> in two totally different ways regarding a Deleter that the pointer may own. Here is the declaration from <a href="http://en.cppreference.com/w/cpp/memory/unique_ptr">cppreference::unique_ptr</a> and <a href="http://en.cppreference.com/w/cpp/memory/shared_ptr">cppreference::shared_ptr</a>:</p>
  
  <pre><code>template&lt;
      class T,
      class Deleter = std::default_delete&lt;T&gt;
  &gt; class unique_ptr;
  
  template&lt; class T &gt; class shared_ptr;
  </code></pre>
  
  <p>As you can see the unique_ptr "saves" the type of the the Deleter-object as a template argument. This can also be seen in the way the Deleter is retrieved from the pointer later on:</p>
  
  <pre><code>// unique_ptr has a member function to retrieve the Deleter
  template&lt;
      class T,
      class Deleter = std::default_delete&lt;T&gt;
  &gt;
  Deleter&amp; unique_ptr&lt;T, Deleter&gt;::get_deleter();
  
  // For shared_ptr this is not a member function
  template&lt;class Deleter, class T&gt;
  Deleter* get_deleter(const std::shared_ptr&lt;T&gt;&amp; p);
  </code></pre>
  
  <p>Can someone explain the rational behind this difference? I clearly favor the concept for <code>unique_ptr</code> why is this not applied to <code>shared_ptr</code> aswell? Also, why would <code>get_deleter</code> be a non-member function in the latter case?</p>