Is this safe to capture a temporary variable in a thread function?
std::vector<std::string> adapterList = getAdapterList();
std::vector<std::thread> captureThreads;
for (auto adapterName : adapterList) {
captureThreads.push_back(std::thread([&] {
// do something with adapterName. Safe?
}));
}
for (auto& thread : captureThreads) {
if (thread.joinable())
thread.join();
}
3