If I have a functor like this…
class DoStuff {
private:
std::vector < int > numericStuff;
public:
explicit DoStuff (const std::vector <int> &newStuff) : numericStuff (newStuff) {};
int operator () (void) {
int ProcessedStuff = 0;
//...Doing stuff
return ProcessedStuff;
};
};
…now, if I wanted to use it normally all I would have to do is…
//...Vector declared and populated somewhere else
DoStuff stuff (Vector);
int someNumber = stuff();
…and there you go. What I want to do is throw it into a boost::thread like this…
DoStuff stuff (Vector);
boost::thread (stuff);
…and then use it, but for the life of me I can’t find out how. Any help would be appreciated.
You can’t do this. To “return a value” from a thread, you have to use Futures.
Quoting from the above documentation: