std::async的使用总结
https://blog.csdn.net/weixin_41191739/article/details/113115847
vecotr<...> async 其中的一种用法:
#include <iostream>
#include <vector>
#include <string>
#include <future>
#include <algorithm>
using namespace std;
string flip(string s) {
reverse(begin(s), end(s));
return s;
}
int main() {
vector<future<string>> v;
v.push_back(async([]{ return flip(" ,olleH"); }));
v.push_back(async([]{ return flip(".gnaL"); }));
v.push_back(async([]{ return flip("\n!TXEN"); }));
for (auto& e : v) {
cout << e.get();
}
}
浙公网安备 33010602011771号