Okay, so I'm trying to switch over to use lambdas in lieu of binds but I'm having some technical difficultah. Namely, can I condense this code?
Code:
/* Create and use a lambda function to count the number of particles contained by the root */
int inside = 0, surface = 0, outside = 0;
auto counter = [](int *inside, int *surface, int *outside, vector<particle> parts, tetra *root) {
int x = 0;
for (auto it = parts.begin(); it < parts.end(); ++it) {
x = inside_tetra(root, &(*it));
if (x == 0) {
ins.lock();
++(*inside);
ins.unlock();
}
if (x == -1) {
out.lock();
++(*outside);
out.unlock();
}
if (x > 0) {
surf.lock();
++(*surface);
surf.unlock();
}
}
return;
};
auto f = [&](unsigned i) { return counter(&inside, &surface, &outside, particle_sets[i], root_tetra); };
for (unsigned i =0; i < num_threads; ++i)
tp.schedule([=]() { return f(i); } );
//tp.schedule(boost::bind(*counter, &inside, &surface, &outside, particle_sets[i], root_tetra));
tp.wait();
cout << "\nThere are " << inside << " points inside the root" << endl;
cout << "There are " << surface << " points on the surface of the root" << endl;
cout << "There are " << outside << " points outside the root" << endl;
cout << inside + surface << " total contained points" << endl;
I think I wind up having to use like 3 lambdas so...
Idk, I kept getting a bunch of weird compilation errors but this works so I'm happy with something that at least works but a more elegant solution would be much appreciated