类崩溃编译器中的 MSVC 2010 模板化映射
MSVC 2010 templated map in class crashing compiler
为什么下面的代码会使编译器崩溃?
#include <iostream>
#include <string>
#include <map>
class test{
public:
template <typename T>
std::map<std::string, T> stuff;
};
int main(int argc, char* argv[])
{
test peanuts;
return 0;
}
编译器中是否有错误还是什么?
您正在尝试使用模板化变量,但只能具有类模板或函数模板。 如果它使编译器崩溃,那么这是一个错误,但它在C++无效。 你可以做类似的事情
class test{
public:
template <typename T>
class Map {
public:
std::map<std::string, T> stuff;
};
};
相反。
相关文章:
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- 将函数类成员映射到类本身内部
- 如何在 C# 中映射双 C 结构指针?
- 如何在C++中使用结构生成映射
- 使用std::函数映射对象方法
- 如何加载(或映射)文件部分的最大大小,但适合在Windows上的RAM
- C++映射分割错误(核心转储)
- 内联映射初始化的动态atexit析构函数崩溃
- 使用"std::unordereded_map"映射到"std::list"对象
- 如何从多映射中删除特定的重复项
- 在未初始化映射的情况下,将值插入到映射的映射中
- QT通过C++添加映射QML项目
- 在c++中访问int到类对象的映射时出错
- 在C++中搜索嵌套多映射值
- 错误处理.将系统错误代码映射到泛型
- C++匿名结构作为std::映射值
- 如何从存储在std::映射中的std::集中删除元素
- 类崩溃编译器中的 MSVC 2010 模板化映射
- Visual C++2010中STL映射的实现与线程安全