JDł*_*osz -6 c++ stl visual-c++-2015
似乎没有任何反对它的规则,以及我得到的错误
std::vector< std::array<int,8> > output;
output.resize (8);
Run Code Online (Sandbox Code Playgroud)
是 C2036 'std::array<int,0x08> *': unknown size
这没有意义.内部的代码<vector>是推进内部end指针,也在其他地方使用(也就是扩展的计算大小).a的大小struct{int x[8];}肯定是"已知的".
这里发生了什么?
嗯,因为它不仅仅是一个简单的拼写错误或者某些东西,并且在其他人尝试它时似乎工作正常(并且其他人写的样本为我工作!)我减少了源文件,直到没有剩下任何东西,但是令人讨厌的陈述,它仍然失败.这是整个文件.预编译的标头已关闭.
//#include <SDKDDKVer.h>
#include <vector>
int main()
{
std::vector< std::array<int,8> > output;
output.resize (16);
}
Run Code Online (Sandbox Code Playgroud)
我正在使用x64构建,发布版本.
这不是一个缺少的#include vector,但是对于array!它显然是在其他标题中向前声明但是不完整.
小智 5
这段代码似乎一切正常.
#include <vector>
#include <array>
int main() {
std::vector< std::array<int,8> > output;
output.resize(8);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
你添加了这#include <array>条线吗?