title: using a custom deleter for std::shared_ptr on a direct3d11 object
body: <p>When i use an std::shared_ptr and need a custom deleter, i usually make a member function of the object to facilitate it's destruction like this:</p>
  
  <pre><code>class Example
  {
  public:
      Destroy();
  };
  </code></pre>
  
  <p>and then when i use the shared ptr, i just make it like this:</p>
  
  <pre><code>std::shared_ptr&lt;Example&gt; ptr(new Example, std::mem_fun(&amp;Example::Destroy));
  </code></pre>
  
  <p>Problem is, right now i'm working with d3d11, and i would like to use the com release functions as an std::shared_ptr custom deleter, like this</p>
  
  <pre><code>std::shared_ptr&lt;ID3D11Device&gt; ptr(nullptr, std::mem_fun(&amp;ID3D11Device::Release));
  </code></pre>
  
  <p>but i get this error:</p>
  
  <pre><code>error C2784: 'std::const_mem_fun1_t&lt;_Result,_Ty,_Arg&gt; std::mem_fun(_Result (__thiscall _Ty::* )(_Arg) const)' : could not deduce template argument for '_Result (__thiscall _Ty::* )(_Arg) const' from 'ULONG (__stdcall IUnknown::* )(void)'
  </code></pre>
  
  <p>and then when i explicitly specify the template paramters like this:</p>
  
  <pre><code>std::shared_ptr&lt;ID3D11Device&gt; ptr(nullptr, std::mem_fun&lt;ULONG, ID3D11Device&gt;(&amp;ID3D11Device::Release));
  </code></pre>
  
  <p>I get this error,</p>
  
  <pre><code>error C2665: 'std::mem_fun' : none of the 2 overloads could convert all the argument types
  </code></pre>
  
  <p>can someone explain why i can't use this function as a deleter?</p>
  
  <p>note: don't suggest I use CComPtr, i'm using msvc++ express edition :\</p>