...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Certain topics in C++ can arouse strong passions, and exceptions are no
exception. We cannot resist mentioning — for purely informational purposes
— that when you need only the first result from some
number of concurrently-running fibers, it would be possible to pass a
shared_ptr<
to the
participating fibers, then cause the initiating fiber to call promise<>
>future::get()
on
its future<>
. The first fiber to call promise::set_value()
on
that shared promise
will
succeed; subsequent set_value()
calls on the same promise
instance will throw future_error
.
Use this information at your own discretion. Beware the dark side.