I come across following code snippet:
......
template <typename SrcIt, typename DstIt, typename Func>
auto par_transform_naive(SrcIt first, SrcIt last, DstIt dst, Func&& func) {
......
auto future = std::async([first, dst, start_idx, stop_idx, &func] {
std::transform(first + start_idx, first + stop_idx, dst + start_idx, func);
});
......
}
......
What confuses me is why the code needs to get a reference of func:
......
auto future = std::async([first, dst, start_idx, stop_idx, &func]
......
Per my understanding, no matter func is deduced as lvaule refernce or rvalue reference, it is all no need to get a reference again.
Aucun commentaire:
Enregistrer un commentaire