Sha256: db3e67b385935aab4bb83d54dcc792dad0c8e29de93886a0f0e75d0bbe96dcc1
Contents?: true
Size: 1.57 KB
Versions: 16
Compression:
Stored size: 1.57 KB
Contents
/** * @file * Declares the base class for scope exit. */ #pragma once #include <functional> namespace leatherman { namespace util { /** * Used to call a function when scope is exited. */ struct scope_exit { /** * Constructs a scope_exit. */ scope_exit(); /** * Constructs a scope_exit. * @param callback The function to call when scope is exited. */ explicit scope_exit(std::function<void()> callback); /** * Moves the given scope_exit into this scope_exit. * @param other The scope_exit to move into this scope_exit. */ scope_exit(scope_exit&& other); /** * Moves the given scoped_resource into this scoped_resource. * @param other The scoped_resource to move into this scoped_resource. * @return Returns this scope_exit. */ scope_exit& operator=(scope_exit&& other); /** * Destructs a scope_exit. */ ~scope_exit(); /** * Invokes the callback. * If called, the callback will not be called upon destruction. */ void invoke(); private: explicit scope_exit(scope_exit const&) = delete; scope_exit& operator=(scope_exit const&) = delete; void* operator new(size_t) = delete; void operator delete(void*) = delete; void* operator new[](size_t) = delete; void operator delete[](void* ptr) = delete; std::function<void()> _callback; }; }} // namespace leatherman::util
Version data entries
16 entries across 16 versions & 2 rubygems