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:
- does
std::future
in c corresponding to promise in javascript? - if 1 is true, why they confused future and promise?
CodePudding user response:
- Yes.
std::future<T>
stands for a future result ofT
, i.e. the object will at some point in the future hold aT
.std::promise<T>
is an object promising to provide aT
at some point in the future.
Which language got the naming right is debatable.