Compilation error : 'this' cannot be implicitly captured in this context
<p>I am trying to add a condition_variable to handle threads, but get a compilation error at this line:</p>

<pre><code>this-&gt;cv.wait(lk, []{return this-&gt;ready;});
</code></pre>

<p>Looks like the for the variable this->ready, the 'this' is not in the right scope.</p>

<p>In Java this can be handled with TestThread.this, is there anything in C++ doing the same?</p>

<pre><code>void TestThread::Thread_Activity()
    {
        std::cout &lt;&lt; "Thread started \n";
        // Wait until ThreadA() sends data
        {
            std::unique_lock&lt;std::mutex&gt; lk(m);
            this-&gt;cv.wait(lk, []{return ready;});
        }

        std::cout &lt;&lt; "Thread is processing data\n";
        data += " after processing";
        // Send data back to ThreadA through the condition variable
        {
           // std::lock_guard&lt;std::mutex&gt; lk(m);
            processed = true;
           // std::cout &lt;&lt; "Thread B signals data processing completed\n";
        }

    }
</code></pre>