推一个静态数组到一个std :: vector的? [英] Pushing a static array into a std::vector?

查看:73
本文介绍了推一个静态数组到一个std :: vector的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做到以下几点:

我有:

std::vector<std::vector<GLdouble[2]>> ThreadPts(4);

然后我尝试做的:

then I try to do:

 GLdouble tmp[2];
  while(step--)
  {


   fx   += dfx;
   fy   += dfy;
   dfx  += ddfx;
   dfy  += ddfy;
   ddfx += dddfx;
   ddfy += dddfy;
   tmp[0] = fx;
   tmp[1] = fy;
   ThreadPts[currentvector].push_back(tmp);
  }

但是,编译器说:

But the compiler says:

错误15错误C2440:初始化:不能转换从'常量GLdouble [2]'到'双[2]C:\\ Program Files文件\\微软的Visual Studio 9.0 \\ VC \\包括\\矢量1211

Error 15 error C2440: 'initializing' : cannot convert from 'const GLdouble [2]' to 'double [2]' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector 1211

我怎么能这样做呢?
我使用VS 2008和唐;吨有性病::数组,我没有提振

How could I do this then? I'm using VS 2008 and don;t have std::array, and I don't have boost.

感谢

推荐答案

一个C风格的数组是不可转让,所以它不能被用来作为一个向量的值类型

A C-style array is not assignable, so it cannot be used as the value type of a vector.

如果您正在使用Visual C ++ 2008 SP1,可以的#include&LT;阵&GT; ,并使用的std :: tr1 ::阵列

If you are using Visual C++ 2008 SP1, you can #include <array> and use std::tr1::array.

即使你不想使用所有的Boost,你应该能够简单地将升压阵头复制到项目,并用它自身的;它不依赖于加速的其他许多地方,以及那些在其上不依靠可方便取出。

Even if you don't want to use all of Boost, you should be able to simply copy the Boost Array header into your project and use it on its own; it doesn't rely on many other parts of Boost, and those on which it does rely can be easily removed.

这篇关于推一个静态数组到一个std :: vector的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆