title: C++ lambda thread stoppable from outside
body: <p>I'm trying to create a helper thread that waiting and works/finishes if the main thead says so.</p>
  <p>Something like this:</p>
  <pre><code>std::atomic&lt;bool&gt; quit(false), doit(false);
  
  std::thread([quit, doit]()
  {
    while (!quit)
    {
      wait();
      if (doit)
        std::cout &lt;&lt; &quot;done&quot;;
    }
  }
  </code></pre>
  <p>the compiler says:</p>
  <pre><code>1.cpp:26:15: error: call to implicitly-del
  eted copy constructor of 'atomic&lt;bool&gt;'
      thread t([quit, doit, ,                   ^~~~~~                      /data/data/com.termux/files/usr/include/c+
  +/v1/atomic:1643:7: note: copy constructor of 'atomic&lt;bool&gt;' is implicitly deleted b
  ecause base class '__atomic_base&lt;bool&gt;' has a deleted copy constructor                  : public __atomic_base&lt;_Tp&gt;
  </code></pre>
  <p>What is the purpose of implicit deletion and why does it matter here?
  Also: what else should I use (and not mutex)?</p>