c++ - Obtaining a function pointer from an iterator over a function deque -


i'm trying build simple deficit round robin scheduler, , right i'm trying function has had least time running. i'm getting "bus error" returned me when try convert iterator pointer. below code, ptof typedef pointer kind of functions have in deque , state has info each process. doing wrong? appreciated.

ptof leasttime(deque<ptof> fnc, map<ptof, state *> s){ double leastelapsed= 100000000; ptof  f;  deque<ptof>::iterator it; (it=fnc.begin() ; < fnc.end(); it++ ){ if(s[*it]->elapsed<leastelapsed){      f = (ptof)(&(*it));  cout<< s[f]->name<<endl;      }   } return f; } 

f = (ptof)(&(*it));  

that taking address of function pointer. try

f = *it; 

in case, avoid c-style casts. if tried static_cast instead, compiler tell cast invalid.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -