3 ms·
int main() { int x = 0; [&x] { x= 1;}(); // works [&x=std::as_const(x)] { x= 1;}(); // error: assignment of read-only reference 'x' } Not ver
by gpderetta 2y ago
int main() {
int x = 0;
[&x] { x= 1;}(); // works
[&x=std::as_const(x)] { x= 1;}(); // error: assignment of read-only reference 'x'
}
Not very pretty, but it works.