I understand that your point is that unique_ptr facilitates resource management. But the example you provide is a misleading. How is this supposed to compile? The deleter type is part of the unique_ptr. So you need something along these lines:<p><pre><code>     auto scope_guard = [](void*) { };
     unique_ptr&lt;void, decltype(scope_guard)&gt; finally{nullptr, scope_guard};
</code></pre>
This is not very idiomatic. Something like toth mentioned makes more sense. If you want it to be efficient, use this:<p><pre><code>    template &lt;class Fun&gt;
    class scope_guard {
      scope_guard() = delete;
      scope_guard(const scope_guard&amp;) = delete;
      scope_guard&amp; operator=(const scope_guard&amp;) = delete;

    public:
      scope_guard(Fun f) : fun_(std::move(f)) {}

      ~scope_guard() {
        fun_();
      }

    private:
      Fun fun_;
    };

    template &lt;class Fun&gt;
    scope_guard&lt;Fun&gt; make_scope_guard(Fun f) {
      return {std::move(f)};
    }

    auto guard = make_scope_guard([] { cleanup(); });
</code></pre>
The difference is: there&#x27;s no indirection through std::function, so you save yourself a (potential) heap allocation.