I have the following function:
void send_sequence_to_device( std::map<const string_t,device_t*> &msg2device_p, std::vector<response_t>& result_list, ushort num_attempts)
{
cout<<"sarit enter to send_seq_device"<<endl;
std::map<const string_t, device_t*>::iterator msg_itf;
for( msg_itf=msg2device_p.begin(); msg_itf!=msg2device_p.end(); msg_itf++ )
{
cout<<"sarit enter to seq "<<msg_itf->first<<endl;
}
}
I call this function by another function:
void node_layer_manager_t::calc_ts_job_function()
{
vector<response_t> res;
map<const string_t, device_t*> getRegMsg={{"get_node_ts_est",&tx},{"get_node_ts_est",&rx},{"get_tx_num_clk_ts",&tx}};
cout<< "sarit ts clk function nlm first"<<endl;
send_sequence_to_device(getRegMsg,res);
}
i can see that the loop iterate only 2 instead of 3. The output is:
sarit enter to seq get_node_ts_est
sarit enter to get_tx_num_clk_ts
While I expect for:
sarit enter to seq get_node_ts_est
sarit enter to seq get_node_ts_est
sarit enter to get_tx_num_clk_ts
A std::map
does not allow duplicate keys.
Two of your values have the same key, hence only one of them will make it into the map.
Use std::multimap
instead of std::map
, if you need duplicate keys.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.