title: How to tell std::future if std::promise exist in C++?
body: <p>I create a <code>std::packaged_task</code>, push it to a <code>std::list</code> and return its <code>std::future</code> to users, like this:</p>
  <pre><code>future_t emplace(...)
  {
      //...
      auto task = std::make_shared&lt;std::packaged_task&lt;return_t()&gt;&gt;(
                  std::bind(std::forward&lt;F&gt;(f), std::forward&lt;Args&gt;(args)...));
      tasks.emplace_back(task);
      std::future&lt;return_t&gt; result = task-&gt;get_future();
      
      //...
      return result;
  }
  </code></pre>
  <p>In another thread, we may clear the tasks list at anytime:</p>
  <pre><code>// another thread
  std::list&lt;task_t&gt; temp_{};
  tasks.swap(temp_);
  </code></pre>
  <p>But users may call std::future still:</p>
  <pre><code>auto result = emplace(...);
  // do something and the tasks list has been clear in anthor thread
  auto ret = result.get();
  </code></pre>
  <p>Get a exception error as std::promise has been destroyed:</p>
  <pre><code>C++ exception with description &quot;std::future_error: Broken promise&quot; thrown in the test body.
  </code></pre>
  <p>I can use a exception expression to avoid the program broken:</p>
  <pre><code>try
  {
      auto ret = result.get();
  }
  catch (...)
  {
  }
  </code></pre>
  <p>Can I avoid <code>std::future_error</code> without exception expression?
  My question is: Is there any other method to detect if the std::promise exist?</p>