// Copyright Takatoshi Kondo 2018 // // 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_SHARED_SCOPE_GUARD_HPP) #define MQTT_SHARED_SCOPE_GUARD_HPP #include #include #include namespace MQTT_NS { template inline auto shared_scope_guard(Proc&& proc) { auto deleter = [proc = std::forward(proc)](void*) mutable { std::forward(proc)(); }; return std::shared_ptr(nullptr, std::move(deleter)); } } // namespace MQTT_NS #endif // MQTT_SHARED_SCOPE_GUARD_HPP