Compilation error : 'this' cannot be implicitly captured in this context

后端 未结 1 1953
不思量自难忘°
不思量自难忘° 2021-02-12 04:14

I am trying to add a condition_variable to handle threads, but get a compilation error at this line:

this->cv.wait(lk, []{return this->ready;});

相关标签:
1条回答
  • 2021-02-12 04:19

    You need to capture the this pointer:

    this->cv.wait(lk, [this]{return ready;});
    
    0 讨论(0)
提交回复
热议问题