Could someone explain what is happening here (GCC 7.3):
#include <thread>
#include <iostream>
struct A
{
struct B {};
};
int main()
{
int var = 0;
std::thread([c=A::B(), var](){ }); // error: ‘var’ was not declared in this scope
std::thread([c=A(), var](){ }); // OK
std::thread([c=A::B(), var=var](){ }); // OK
return 0;
}
When I capture nested struct I got:
'var' was not declared in this scope
On the other hand, capturing non-nested struct works. Also capturing with initialization works. Also all cases work in Visual Studio.