能吧,这样写我编译执行通过了。
g++ -v
gcc version 15.1.0 (Rev5, Built by MSYS2 project)
g++ -std=c++23 test.cc -o test
[code=c++]
#include <iostream>
struct Example {
int value = 42;
void demo() {
auto lambda = [](auto& self, int x) -> int {
return self.value + x;
};
std::cout << lambda(*this, 8) << std::endl;
}
};
int main() {
Example e;
e.demo(); // 输出 50
}
[/code]
--
FROM 171.213.144.*