I saw the uses of std::future
in the program written in C++. So, I quickly went to lookup what is is: std::future and got a quite complicated answer for me.
Can someone put it in simple words for a 6 years old kid? I have an understanding level of a 6 years old kid...
Just a small definition with a minimal use case will work for me. Let me know if it is too much to ask and I'll take back my question.
A std::future<T>
is a handle to a result of work which is [potentially] not, yet, computed. You can imagine it as the receipt you get when you ask for work and the receipt is used to get the result back. For example, you may bring a bike to bike store for repair. You get a receipt to get back your bike. While the work is in progress (the bike being repaired) you can go about other business. Eventually, when the work is supposed to be done you ask for the result (the repaired bike) and [potentially] wait until the result is delivered.
std::future<T>
is a general mechanism to receive result. It doesn't prescribe how the requested work is actually executed.