1

Here's my desired code:

class Machine {

private:
   QSet<State*> states;
   State* step(State* st){/*...*/}

public:
   void makeStep(){
        //...
        QTConcurrent::map(states, step);
        //...
   }

My problem: This doesn't compile, since step() is neither a global function nor a member of State. But logically this would be correct, because step() does not modify a thing - it only accesses a structure of maps, but again, read-only.

What should to get modified, however, is the set states. I wanted to be smart and modify each State* concurrently (in a non-blocking fashion).

Should I make step() global? Would it help?

Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103
TeaOverflow
  • 2,468
  • 3
  • 28
  • 40
  • I cant, since Im using a member of the object. Its what `step()` is about – TeaOverflow Nov 25 '11 at 13:29
  • 4
    As the [documentation](http://doc.qt.nokia.com/4.7-snapshot/qtconcurrentmap.html#using-bound-function-arguments) suggests, have you tried `std::bind(&Machine::step, this)` for the function? – Kerrek SB Nov 25 '11 at 13:33
  • I ended up binding `step()` to a function object. [Watch me struggle](http://stackoverflow.com/questions/13647319/stdbind-this-and-qtconcurrent) – TeaOverflow Dec 01 '13 at 17:37

0 Answers0