为什么这个代码能够工作:
std::pair<int, int> p = {1,2};
std::vector<std::pair<int, int>> vp = { {1,2}, {3,4} };
但这不行吗?
std::array<int, 2> a = {1,2}; // still ok
std::vector<std::array<int, 2>> va = { {1,2}, {3,4} };
使用带有-std=c++0x
编译选项的g++ 4.5.1版本,第二行代码失败并显示以下错误信息:
error: could not convert
‘{{1, 2}, {3, 4}}’
to‘std::vector<std::array<int, 2u> >’
谢谢。