6
我一直在尝试使用新的0X标准初始化<ints, vector<ints> >
的地图,但我似乎无法获得正确的语法。我想使用带有密码的单个条目的映射:值= 1:< 3,4>在矢量地图上使用initializer_list
#include <initializer_list>
#include <map>
#include <vector>
using namespace std;
map<int, vector<int> > A = {1,{3,4}};
....
它裸片与使用gcc 4.4.3以下错误:
error: no matching function for call to std::map<int,std::vector<int,std::allocator<int> >,std::less<int>,std::allocator<std::pair<const int,std::vector<int,std::allocator<int> > > > >::map(<brace-enclosed initializer list>)
编辑
继齿轮的建议,并添加额外的支柱,现在与可摆脱了使用-fno-演绎-初始化列表标志的警告编译。这样做有没有危险?
是不是你错过了大括号? – YGL 2010-05-17 20:22:55
@ YGL - 修好了谢谢。尽管如此,仍然不能解决原来的问题。 – Hooked 2010-05-17 20:27:13
在4.4.1上,编译器遭受精神崩溃(内部错误)。也许与4.5它工作正常? – ergosys 2010-05-17 20:33:51