#pragma once
#include <functional>
#define CONNECTION(text1,text2) text1##text2
#define CONNECT(text1,text2) CONNECTION(text1,text2)
class DeferHelper {
public:
DeferHelper(std::function<void ()> &&cb) : cb_(std::move(cb)) {}
~DeferHelper() { if (cb_) cb_(); }
C++实现defer
最新推荐文章于 2023-12-27 09:10:10 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)