//------------------------------------------------------------------------------
struct A
{
A(){}
A(A&&){}
A& operator=(A&&){return *this;}
void operator()(){}
private:
A(const A&);
A& operator=(const A&);
int x;
};
//------------------------------------------------------------------------------
int main()
{
A a;
std::function<void()> func(std::move(a));
}
'A::A' : cannot access private member declared in class 'A'
It seems like when I capture something by reference or const
I can make a non-copyable lambda. However when I do that it actually works to give it to a std::function
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…