RAII object for releasing pointer with arbitrary function
unique_ptr has capability for custom deleters.

Besides that assuming you are doing this to deal with COM objects then you can use ComPtr and its GetAddressOf



If you define a destructor you should also define (or disallow in this case) the copy construct and copy assign. Failure to do so will result in dangling pointers and double frees:

Releaser&lt;IMFAttributes&gt; attributes;
auto status = MFCreateAttributes(attributes.fill(), 1);
{
    Releaser&lt;IMFAttributes&gt; att = attributes;
} // att gets cleaned up

//attributes contains a dangling pointer