// Copyright Takatoshi Kondo 2022 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #if !defined(MQTT_UNIQUE_SCOPE_GUARD_HPP) #define MQTT_UNIQUE_SCOPE_GUARD_HPP #include #include #include namespace MQTT_NS { template inline auto unique_scope_guard(Proc&& proc) { auto deleter = [proc = std::forward(proc)](void*) mutable { std::forward(proc)(); }; return std::unique_ptr(&deleter, force_move(deleter)); } } // namespace MQTT_NS #endif // MQTT_UNIQUE_SCOPE_GUARD_HPP