I am trying to find if a string words contains any instruction form machine_opTable, a vector of pair-string,int.
What should my lambda function look like in find_if ? If you have any other approach, please let me know.
As of now, my code looks like ...
# define RX 4
# define RR 2
...
vector < pair <string, int> > machine_opTable = { {"L", RX},
{ "A", RX},
{"ST", RX}
};
words = " L 1, SMB1";
string inMachineop;
for ( auto instruction: words){
inMachineop = find_if ( begin(machine_opTable), end(machine_opTable), [] (const pair<string,int>& p) { return ( p.first == instruction ? p.first : "NOTFOUND"); });
}
I would love to return iterator pointing to that pair... Please show me how it's done.
Thank you.