20 Star 43 Fork 13

GiteeStudio/git-analyze

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
finaly.hpp 828 Bytes
一键复制 编辑 原始数据 按行查看 历史
江二十三 提交于 6年前 . [all] rewrite cmd_main
////////////
#ifndef AZE_FINALY_HPP
#define AZE_FINALY_HPP
#include <memory>
namespace aze {
template <class F> class final_act {
public:
explicit final_act(F f) noexcept : f_(std::move(f)), invoke_(true) {}
final_act(final_act &&other) noexcept
: f_(std::move(other.f_)), invoke_(other.invoke_) {
other.invoke_ = false;
}
final_act(const final_act &) = delete;
final_act &operator=(const final_act &) = delete;
~final_act() noexcept {
if (invoke_)
f_();
}
private:
F f_;
bool invoke_;
};
// finally() - convenience function to generate a final_act
template <class F> inline final_act<F> finally(const F &f) noexcept {
return final_act<F>(f);
}
template <class F> inline final_act<F> finally(F &&f) noexcept {
return final_act<F>(std::forward<F>(f));
}
} // namespace aze
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/oscstudio/git-analyze.git
git@gitee.com:oscstudio/git-analyze.git
oscstudio
git-analyze
git-analyze
master

搜索帮助