Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

insert to boost unordered map

Hi I'm trying to insert a record into a boost::unordered_map

Map is defined as

boost::unordered_map<int,Input> input_l1_map;

where Input is the class

class Input {

        int id;
        std::string name;
        std::string desc;
        std::string short_name;
        std::string signal_presence;
        std::string xpnt;
        }

I use a function to insert the record as below

void RuntimeData::hash_table(int id,Input input)
{

  this->input_l1_map.insert(id,input);

}

I read the boost documentation it says a function insert() to insert data to the container, but when I compile it shows error.

like image 405
Jishnu U Nair Avatar asked Nov 16 '25 17:11

Jishnu U Nair


1 Answers

Where you find such insert method?

  std::pair<iterator, bool> insert(value_type const&);
  std::pair<iterator, bool> insert(value_type&&);
  iterator insert(const_iterator, value_type const&);
  iterator insert(const_iterator, value_type&&);
  template<typename InputIterator> void insert(InputIterator, InputIterator);

Where value_type is

  typedef Key                                    key_type;            
  typedef std::pair<Key const, Mapped>           value_type;

from here

You should use this->input_l1_map.insert(std::make_pair(id, input));

like image 169
ForEveR Avatar answered Nov 19 '25 09:11

ForEveR