#ifndef MIGRAPH_GUARD_MIGRAPH_MANAGE_PTR_HPP #define MIGRAPH_GUARD_MIGRAPH_MANAGE_PTR_HPP #include #include #include namespace migraph { inline namespace MIGRAPH_INLINE_NS { 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 // NOLINT 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 MIGRAPH_INLINE_NS } // namespace migraph #define MIGRAPH_MANAGE_PTR(T, F) \ migraph::manage_ptr, decltype(&F), &F> // NOLINT #endif