不能在增强/unordered_map中使用矢量
Can not use a vector in boost/unordered_map
我正在使用unordered_map,但我无法将指针向量声明为值。我有以下声明:
//file test.h
#include <boost/unordered_map.hpp>
#include <boost/foreach.hpp>
struct Record
{
char **data;
};
typedef boost::unordered_map<std::string, std::vector<Record*> > MAP;
typedef std::pair<std::string,std::vector<Record*> > PAIR;
我已经在test.cpp中包含这个头文件,当我使用g ++编译时,出现以下错误:
/usr/include/boost/detail/container_fwd.hpp:80: error: provided for ‘template<class T, class Allocator> struct std::vector’
test.h:10: error: template argument 2 is invalid
test.h:10: error: template argument 5 is invalid
test.h:10: error: invalid type in declaration before ‘;’ token
知道这个错误是什么意思吗?
您缺少std::vector
和std::string
分别需要的vector
和string
标头。
您也应该包括utility
,以便std::pair
。这可能包含在boost/unordered_map.hpp
中,但您不应该依赖它。
#include <vector>
#include <string>
#include <utility>
相关文章:
- 如何导出包含具有"std::unique_ptr"值的"std::map"属性的
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- 使用一个考虑到std::map中键值的滚动或换行的键
- 无法将结构注册为增强几何体3D点
- 为什么 const std::p air<K,V>& 在 std::map 上基于范围的 for 循环不起作用?
- 允许从 std::map 的密钥窃取资源?
- 有没有办法对std::unordered_set、std::unrdered_map、std::set、std::map
- 将重物插入std::map
- 增强基于 XML class_id的反序列化
- 使用通用值初始化 std::map,不重复
- 仅包含可移动 std::map 的类的移动构造函数不起作用
- 增强精神解析器规则以检测语句中的特殊结尾
- C++:当所有条目都保证是唯一时,替代 std::map
- C++ 使用增强正则表达式库时断言崩溃
- 使用模板化的键类型定义 std::map,该键类型基于作为参数接收的函数
- 如果 KEY 是 std::list 或 std::vector 而不是值,那么 std::map 的默认行为是什么?
- 增强精神 X3:错误:在"..."中没有名为"大小"的类型
- 使用字符数组作为 Map 中的键
- C++如何创建 std::map
- C++ equivalent to Java Map getOrDefault?