[英]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;
};
};
代替。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.