注意:这篇文章上次更新于1462天前,文章内容可能已经过时。
This article was last updated1462 days ago, the content may be outdated.
分享一个在公司看到的头文件。
1 |
|
使用方法:
- 如果你想写一个删除掉拷贝构造函数和拷贝赋值函数的类,那么你可以继承 disable_copying_and_assignment
1 | class myclass : public disable_copying_and_assignment |
- smart_lambda 有点类似于 lock_guard ,在离开作用域时执行函数。一个可能的使用场景是当你的函数中存在许多分支,但是return之前必须做一件相同的事,使用 smart_lambda 可以避免代码的重复。
1 | void function(int index) |
这样无论从哪个分支结束,都会输出函数执行结束了。
smart_both_lambda 和 smart_condition_lambda 的功能也显而易见。


