c++11 STD数组- GCC与visual studio的区别
c++11 std array - differences between gcc and visual studio
我对这部分代码有一个问题:
typedef std::array<u32, 3> my_array;
void foo()
{
my_array a1{{1, 2, 3}};
a1 = {{1, 2, 3}}; // PROBLEM - does not work;
my_array a2{{3, 2, 1}};
a1 = a2;
}
GCC 4.7也可以编译这段代码,但是Visual studio with cl从2012年11月开始编译失败了:
error C2679: binary '=' : no operator found which takes a right-hand
operand of type 'initializer-list' (or there is no acceptable
conversion) 1> C:Program Files (x86)Microsoft Visual Studio
11.0VCINCLUDEarray(211): could be 'std::array<u32,3> &std::array<u32,3>::operator =(const std::array<u32,3> &)' 1>
while trying to match the argument list '(my_array, initializer-list)'
语法是否正确,是否符合c++11标准?我找不到关于这个的任何信息,不知道我应该责怪哪个编译器。提前感谢你的帮助。
问好。
正如我所说,VS2012
有点蹩脚,C++11
有一些困难,如果你想要一个列表,看这里。
相关文章:
- Visual Studio 2015:Extern "C" 和 "export" 关键字
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 试图在visual studio上用C++创建一个桌面应用程序
- 如何在MS Visual Studio 2019中运行QT UI
- 如何使用Visual Studio 2017在C++中为参数化对象数组使用唯一指针
- Visual Studio Code - C++ Debugger 無法啟動
- Visual Studio 2019:插入多个C++风格的单行注释
- Visual Studio Code "undefined reference to `WinMain@16'"
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- Visual Studio中的函数声明和函数定义问题
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- Visual Studio mkl_link_tool.exe链接错误
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 不同的Visual Studio版本中缺少.dll
- 用Visual Studio在C++中嵌入Julia
- Visual Studio 2017循环自动向量化问题
- 有没有办法在远程设备上打开和编辑visual Studio 2017解决方案
- 尝试使用继承和模板实现CRTP.Visual Studio正在生成编译器错误
- Visual Studio在尝试读取resource.txt文件时崩溃
- Visual Studio 2017 不允许我创建 C++ 专用模板