void A::f()
{
auto fn = [this](this auto){
A_mem_func();
};
…
}
编译是过不了的,说deduce this是static function,不能用this。
问题是lambda函数体内的this并不指向lambda object,而是指向encapsulating class的this啊。
gcc一直过不了,需要捕获thisptr = this, 然后 thisptr->A_mem_func(); 来绕过这个bug。
也不知道gcc 15修了没,还是说有啥别的考虑。
- 来自 水木社区APP v3.5.7
--
FROM 116.169.10.*