I am a c++ programmer and tried to study std::future
and std::promise
these days. When I randomly search some information about future/promise, I found some discussion about future/promise in javascript and promise in javascript has then
function. In c++, even though std::future
don't have then
function now, but some proposal have mentioned it. So, there are two question:
std::future
in c++ corresponding to promise in javascript?std::future<T>
stands for a future result of T
, i.e. the object will at some point in the future hold a T
. std::promise<T>
is an object promising to provide a T
at some point in the future.Which language got the naming right is debatable.