I have a struct like this:
/* Renderable definition */
struct Renderable
{
Renderable(VertexBufferPtr vertexBuffer, const Mat4& wvpMatrix, const Mat4& worldMatrix, const Vec4& diffuseColor, const float specularFactor) :
mVertexBuffer(vertexBuffer), mTransform(wvpMatrix, worldMatrix), mMaterial(diffuseColor, specularFactor)
{
}
/* Transform definition */
struct Transform
{
Transform(const Mat4& wvpMatrix, const Mat4& worldMatrix) : mWVPMatrix(wvpMatrix), mWorldMatrix(worldMatrix)
{
}
const Mat4 mWVPMatrix;
const Mat4 mWorldMatrix;
};
/* Material definition */
struct Material
{
Material(const Vec4& diffuseColor, const float specularFactor) : mDiffuseColor(diffuseColor), mSpecularFactor(specularFactor)
{
}
const Vec4 mDiffuseColor;
const float mSpecularFactor;
};
const VertexBufferPtr mVertexBuffer;
const Transform mTransform;
const Material mMaterial;
};
/* RenderQueue definition */
typedef std::vector<Renderable> RenderQueue;
When I try to use it in my code like this;
RenderQueue CreateRenderQueue(const Scene* scene);
....
RenderQueue renderQueue(CreateRenderQueue(activeScene));
I get the follow compile error:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2514): error C2582: 'operator =' function is unavailable in 'Renderable'
After some digging I came to realise it was because I had not defined the assignment operator and the copy-constructor. I then did so, and voilah! it compiled...
....My question is however, why is the assignment operator and the copy constructor NOT implicitly generated by the compiler? (vs2010) I did not define them, so surely they would be generated?
Thanks