foreach - Member function pointer in C++ for_each -


i'm developing small virtual machine in c++ school project, should work dc command, , composed of input output element, chipset, cpu , ram. i'm working on chipset, in i've implemented little parsing class in order able asm instructions standard input or file, , push instructions cpu.

the problem is: instructions sorted in std::list, , i'd able push them each each foreach instruction. need able call member function "push_instruction" function pointer f of for_each; , wasn't able find trick that...

any ideas? here's code:

/* ** function supervise ** lexing , parsing of input (whether it's std_input or file descriptor) ** memory pushing of operands , operators ** , command execution of instructions cpu */ void                    chipset::startexecution() {     /*     ** parsing      ** instructions     **     */      for_each(this->_instructlist.begin(), this->_instructlist.end(), this->pushinstruction); }   void                    chipset::pushinstruction(instructionlist* instruction) {     if (instruction->opcode == push)       this->_processor->pushoperand(instruction->value, memory::operand, memory::back);     else if (instruction->opcode == assert)       this->_processor->pushoperand(instruction->value, memory::assert, memory::back);     else       this->_processor->pushoperation(instruction->opcode); } 

std::for_each(     _instructlist.begin(),      _instructlist.end(),      std::bind1st(std::mem_fun(&chipset::pushinstruction), this)); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -