gpt4 book ai didi

c++ - 插入以 boost 无序 map

转载 作者:太空狗 更新时间:2023-10-29 21:02:17 24 4
gpt4 key购买 nike

您好,我正在尝试将记录插入到 boost::unordered_map

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;
}

我使用一个函数来插入记录,如下所示

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

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

}

我阅读了 boost 文档,它说一个函数 insert() 将数据插入容器,但是当我编译时它显示错误。

最佳答案

你在哪里找到这样的insert方法?

  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;

来自 here

你应该使用 this->input_l1_map.insert(std::make_pair(id, input));

关于c++ - 插入以 boost 无序 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15833847/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com