class A{
public:
void do_something(std::function<void()> const& f) {
}
};
class B: public A{
public:
int x = 0;
void do_another_thing(){
do_something([x]{});
}
};
It says that x is not a variable:
16:20: error: capture of non-variable 'B::x'
14:13: note: 'int B::x' declared here
Why it won't work with a class member but it will work with variables defined inside do_another_thing()?