I have an array of pthread_ts which are started within a for-loop via pthread_create.
I have a ton of variables that are declared beforehand and are important for the inner workings of the thread. I would like to have an anonymous inner function as start-routine of the pthread_create like so:
pthread_create(threads[i], NULL,
{ inner function here }
, NULL);
I know that C++ doesn't have this in particular so I thought maybe lambdas could be of help or maybe someone has another idea so that I do not have to create a seperate method and hand over all those variables that come before pthread_create.
std::threadinstead? The standard threads support lambdas, IIRC. Since you mention lambdas, you probably havestd::threadtoo.std::threadas well.std::thread. Is it possible with pthreads?std::threadwould not be usable/possible while lambdas are?std::threadas well. They both came with the C++11 standard. Can you please elaborate on why you "cannot usestd::thread"?