Here is the example code snippet:
#include<future>
#include<iostream>
int main()
{
    auto f=[](){
        std::promise<int> promise_;   //Since `promise_` is a local variable, is there any potential problem?
        auto future_ = promise_.get_future();
        promise_.set_value(1);
        return future_;
    }();
    std::cout << f.get() << std::endl;
}
Aucun commentaire:
Enregistrer un commentaire