#pragma once #include "UiApplication.h" #include #include #include namespace cru::platform::gui { template class DeleteLaterImpl { CRU_DEFINE_CLASS_LOG_TAG("cru::platform::gui::DeleteLaterImpl") public: virtual ~DeleteLaterImpl() {} void DeleteLater() { IUiApplication::GetInstance()->DeleteLater(static_cast(this)); } }; namespace details { template struct DeleteLaterPtrDeleter { void operator()(T* p) const noexcept { p->DeleteLater(); } }; } // namespace details template using DeleteLaterPtr = std::unique_ptr>; template DeleteLaterPtr ToDeleteLaterPtr(std::unique_ptr&& p) { return DeleteLaterPtr(p.release()); } template DeleteLaterPtr MakeDeleteLater(Args&&... args) { return DeleteLaterPtr(new T(std::forward(args)...)); } } // namespace cru::platform::gui