那就用 std::enable_shared_from_this 这个工具,在捕获 this 的时候,变成 shared_ptr<> 增加一个引用。
【 在 allegro 的大作中提到: 】
: 老鱼,这个即便使用shared_ptr也逃不过use-after-free的。
: 因为"存在lambda里面的那个shared_ptr"已经被析构了,而不是说"那个shared_ptr指向的对象"已经被析构了。
: lambda coroutine的问题就在于c逃出了this的生命周期。
: ...................
--
FROM 27.152.129.*