我不想用std::multimap,因為我希望能夠使用index隨機取得value部分的值,于是便希望定義一個std::map<int, std::vector<int>>的類型,結果在vc6中死活編譯不過。我寫的測試代碼為:std::map<int, std::vector<int>> test_map; 結果報錯如下:
D:\me\document\VC6\test\test.cpp(34) : error C2146: syntax error : missing ',' before identifier 'test_map'
D:\me\document\VC6\test\test.cpp(34) : error C2065: 'test_map' : undeclared identifier
D:\me\document\VC6\test\test.cpp(34) : error C2143: syntax error : missing '>' before ';'
于是改寫成如下代碼:
typedef std::vector<int> IntVector;
typedef std::map<int, IntVector> IntVectorMap;
IntVectorMap test_map;
順利編譯通過 -_- 還真是邪門了。
注:std::map<int, std::vector<int>> test_map; 在vs2005下順利編譯通過。