title: Run loop in `std::future` until destruction - idiomatic way?
body: <p>I want a member <code>std::future&lt;void&gt;</code> to continuously call a function inside a loop until the parent object is destroyed. </p>
  
  <p>My current solution involves wrapping the future in a class with a boolean flag and setting the flag to false on destruction.</p>
  
  <pre><code>class Wrapper
  {
      std::future&lt;void&gt; fut;
      bool wrapperAlive{true};
  
  public:
      Wrapper() : fut{std::async(std::launch::async, [this]
      { 
          while(wrapperAlive) doSomething();
      })} { }
  
      ~Wrapper()
      {
          wrapperAlive = false;
      }
  };
  </code></pre>
  
  <p>Is there a more idiomatic way of doing this?</p>