I'm having difficulty passing an array of integers to a function using std::thread. It seems like thread doesn't like the array portion of it. What other way is there to pass an array to a threaded function?
#include <thread>
#include <ostream>
using namespace std;
void process(int start_holder[], int size){
for (int t = 0; t < size; t++){
cout << start_holder[t] << "\n";
}
}
int main (int argc, char *argv[]){
int size = 5;
int holder_list[size] = { 16, 2, 77, 40, 12071};
std::thread run_thread(process,holder_list,size);
//std::ref(list) doesnt work either
//nor does converting the list to std::string then passing by std::ref
run_thread.join();
}
using namespace std;. In fact, don't say it anyway.std::thread, or is itint list[size] = { 16, 2, 77, 40, 12071};, which doesn't work with Clang despite the VLA extension?size's type toconst int.