Can't push vector of vector of GlDouble?
I have a vector which accepts vectors of GlDouble vectors. But when I try to push one it says:
Error 1 error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'std::vector<_Ty>' to 'const std::vector<_Ty> &' c:\Users\Josh\Documents\Visual Studio 2008\Projects\Vectorizer Project\Vectorizer Project\Vectorizer Project.cpp 324
Why isn't it letting me push this? It's saying it wants a contant but I never specified that....
Thanks
the struct:
struct SHAPECONTOUR{
std::vector<USERFPOINT> UserPoints;
std::vector<std::vector<GLdouble&g开发者_如何学编程t;> DrawingPoints;
};
std::vector<std::vector<GLdouble>> shape_verts;
SHAPECONTOUR c;
c.DrawingPoints.push_back(shape_verts);
Edit: After new additions, the problem is not const - the problem is that you're trying to push the wrong type.
std::vector<std::vector<GLdouble> > v;
v.push_back(std::vector<GLdouble>()); // works; pushing contained type
v.push_back(std::vector<std::vector<GLdouble> >()); // <-- error: trying to push type of container.
Think about if you just had a vector of doubles; you push_back a double into the vector, you don't push_back another vector.
This has nothing to do with const. Your types are wrong. DrawingPoints
is a std::vector<std::vector<GLdouble>>
which means that it contains items of type std::vector<GLdouble>
. You're trying to push_back(shape_verts)
which is of type std::vector<std::vector<GLdouble>>
. I think what you want is just to make shape_verts
a std::vector<GLdouble>
.
精彩评论