#ifndef RTG_GUARD_RTG_MANAGE_PTR_HPP #define RTG_GUARD_RTG_MANAGE_PTR_HPP #include #include namespace rtg { template // NOLINT struct manage_deleter { template void operator()(T* x) const { if(x != nullptr) { f(x); } } }; struct null_deleter { template void operator()(T*) const { } }; template using manage_ptr = std::unique_ptr>; template struct element_type { using type = typename T::element_type; }; template using remove_ptr = typename std:: conditional_t{}, std::remove_pointer, element_type>::type; template using shared = std::shared_ptr>; template shared share(T p) { return shared{std::move(p)}; } } // namespace rtg #define RTG_MANAGE_PTR(T, F) rtg::manage_ptr, decltype(&F), &F> // NOLINT #endif