std::array 和 VS2015 的错误 [英] error with std::array and VS2015
问题描述
我有很久以前写的代码,现在我不怎么做C++"了.我已经在Visual C++ 2010 Express"中编译了没有问题的代码.我已经在 vs2015 中编译了它,但出现了std::array"错误.有人可以解释一下我的错误吗.
I have code that I wrote quite a while ago, and I don't do that much 'C++' these days. I've compiled the code with no issues in 'Visual C++ 2010 Express'. I've compiled it in vs2015 and I get an error with the 'std::array'. Could someone be kind enough to explain my error.
这在Visual C++ 2010 Express"中编译正常
This compiled ok in 'Visual C++ 2010 Express'
// create arrays to hold port write data
array<DataChunk>^ dataArray = gcnew array<DataChunk>(1008);
但是在vs2015编译时报错:
But compiled in vs2015 with the error:
1>c:\users\carl\desktop\pond control\pond control\Form1.h(1199): error C2976: 'std::array': too few template arguments
1> C:\Program Files\Microsoft Visual Studio 14.0\VC\include\utility(306): note: see declaration of 'std::array'
任何帮助将不胜感激.
推荐答案
std::array 是封装常规"固定大小数组的容器数据类型.您需要提供数组大小作为模板参数:
std::array is a container data type that encapsulates "regular" fixed-size arrays. You need to provide the array size as a template parameter:
auto dataArray = gcnew array<DataChunk,1008>();
这篇关于std::array 和 VS2015 的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!