摘要: 在使用std::thread时遇到问题,代码简化如下: #include <iostream> #include <thread> #include <string> int main(int argc, char** argv) { auto show = [](const std::string 阅读全文
posted @ 2021-12-16 13:09 亚九 阅读(762) 评论(0) 推荐(0) 编辑
摘要: lambda可以捕获局部变量,但无法显式捕获类成员。如果在lambda中指定 auto func = [=](){}; 以传值方式捕获所有变量,将捕获this,从而可访问类成员。例如下列伪代码, class foo { public: void show() const { auto print = 阅读全文
posted @ 2021-12-16 11:44 亚九 阅读(5143) 评论(0) 推荐(1) 编辑