feat update

This commit is contained in:
tqcq 2024-03-18 15:21:50 +08:00
parent 051117ac08
commit b23f0c35e0

View File

@ -23,20 +23,18 @@ WasDeduced()
} }
}// namespace internal }// namespace internal
template<typename Arg = internal::Tag, template<typename Arg = internal::Tag, typename Callback = std::function<void()>>
typename Callback = std::function<void()>>
class Cleanup final { class Cleanup final {
public: public:
static_assert(internal::WasDeduced<Arg>(), static_assert(internal::WasDeduced<Arg>(), "Do not specify the first template argument");
"Do not specify the first template argument");
Cleanup(Callback callback) : callback_(std::move(callback)) {} Cleanup(Callback callback) : callback_(std::move(callback)) {}
Cleanup(Cleanup &&other) = default; Cleanup(Cleanup &&other) = default;
void Cancel() && { callback_.reset(); } void Cancel() { callback_.reset(); }
void Invoke() && void Invoke()
{ {
assert(callback_); assert(callback_);
(*callback_)(); (*callback_)();