Commit b23f0c35 authored by tqcq's avatar tqcq
Browse files

feat update

parent 051117ac
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -23,20 +23,18 @@ WasDeduced()
}
}// namespace internal

template<typename Arg = internal::Tag,
         typename Callback = std::function<void()>>
template<typename Arg = internal::Tag, typename Callback = std::function<void()>>
class Cleanup final {
public:
    static_assert(internal::WasDeduced<Arg>(),
                  "Do not specify the first template argument");
    static_assert(internal::WasDeduced<Arg>(), "Do not specify the first template argument");

    Cleanup(Callback callback) : callback_(std::move(callback)) {}

    Cleanup(Cleanup &&other) = default;

    void Cancel() && { callback_.reset(); }
    void Cancel() { callback_.reset(); }

    void Invoke() &&
    void Invoke()
    {
        assert(callback_);
        (*callback_)();