How can we create a pointer in a c++ lambda capture list? For example, we can create an integer variable and make the lambda stateful:
auto lambda1 = [a = int{ 5 }]() mutable {
a = 3;
}
However, when we change a to a pointer, the compiler doesn't work:
auto lambda2 = [a = void* { nullptr }]() mutable {
a = ...;
}
Another workaround is to declare a pointer outside and then copy it, but this seems very redundant
void* a;
auto lambda3 = [a]() mutable {
a = ...
}