Hi,
While developming my engine/ framework I've encountered the following situation:
- let's say I have class A: mySomethingClass and class B: mySomethingClassMgr
- class B has a member std::vector<mySomethingClass>
- I use the std::vector functions to use, fill and manage the std::vector in class B
But when I make the copy/ move constructors/assignment 'deleted'/ not allowed in class A, the std::vector functions don't work anymore, including "emplace_back".
// CD3dShaderPack(const CD3dShaderPack& other) = delete; // copy constructor: not allowed
// CD3dShaderPack(CD3dShaderPack&& other) = delete; // move constructor: not allowed
// CD3dShaderPack& operator=(const CD3dShaderPack& other) = delete; // copy assignment: not allowed
// CD3dShaderPack& operator=(CD3dShaderPack&& other) = delete; // move assignment: not allowed
mShaderPacks.emplace_back();
private:
std::vector<CD3dShaderPack> mShaderPacks;
My conclusion from this, is that "emplace_back" is somehow using a copy or move constructor/assignment.
The error I get when I not comment out the 4 lines above, is:
error C2280: 'Crealysm::D3DRENDERER::CD3dShaderPack::CD3dShaderPack(Crealysm::D3DRENDERER::CD3dShaderPack &&)': attempting to reference a deleted function
1> e:\projects\crealysm11\crealysm11\d3drenderer\cd3dshaderpack.h(32): note: see declaration of 'Crealysm::D3DRENDERER::CD3dShaderPack::CD3dShaderPack'
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0(857): note: see reference to function template instantiation 'void std::allocator<_Ty>::construct<_Objty,_Ty>(_Objty *,_Ty &&)' being compiled
1> with
1> [
1> _Ty=Crealysm::D3DRENDERER::CD3dShaderPack,
1> _Objty=Crealysm::D3DRENDERER::CD3dShaderPack
1> ]
When I comment out the 1st, 2nd and 4th and keep the 'copy assignment' = delete in place, it also works.
So it's a combination of the other 3 that gives the problem (tried all combinations, all 'NOK').
Do you know if there's a way to use the std::vector in class B with class A objects, without allowing copy/move constructor/assignment for class A?