Inquiring minds want to know this classic question:
What is std::promise?
I'm fairly familiar with the new standard library's
std::thread
,std::async
andstd::future
components (e.g. see this answer), which are straight-forward.However, I cannot quite grasp what
std::promise
is, what it does and in which situations it is best used. The standard document itself doesn't contain a whole lot of information beyond its class synopsis, and neither does just::thread.Could someone please give a brief, succinct example of a situation where an
std::promise
is needed and where it is the most idiomatic solution?
Add a Comment
Comments are closed.