插入以增强无序地图 [英] insert to boost unordered map
本文介绍了插入以增强无序地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将记录插入boost :: unordered_map
Hi I'm trying to insert a record into a boost::unordered_map
地图定义为
boost::unordered_map<int,Input> input_l1_map;
其中Input是类
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);
}
我阅读了boost文档,其中显示了一个函数insert()
,可以将数据插入容器,但是在编译时却显示错误.
I read the boost documentation it says a function insert()
to insert data to the container, but when I compile it shows error.
推荐答案
在哪里找到这样的insert
方法?
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);
value_type
所在的位置
typedef Key key_type;
typedef std::pair<Key const, Mapped> value_type;
来自此处
您应该使用this->input_l1_map.insert(std::make_pair(id, input));
这篇关于插入以增强无序地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文