我有這樣的結構:爲什麼在這種情況下operator =和copy-constructor不是隱式生成的?
/* 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;
當我嘗試在我的代碼這樣使用它;
RenderQueue CreateRenderQueue(const Scene* scene);
....
RenderQueue renderQueue(CreateRenderQueue(activeScene));
我得到後續編譯錯誤:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2514): error C2582: 'operator =' function is unavailable in 'Renderable'
一些挖我才意識到那是因爲我還沒有定義的賦值操作符和拷貝構造函數後。然後我這樣做了,瞧!它編譯...
....我的問題是,然而,爲什麼賦值操作符和拷貝構造函數不會隱式由編譯器產生的? (vs2010)我沒有定義它們,所以它們肯定會生成?
謝謝
什麼是'VertexBufferPtr'?它是可複製的嗎? –