Jul 9, 2015 at 9:28pm UTC
I'm trying to copy another class' vector to cActionPuppet with the following code.
(I apologize for any formatting issues, for some reason, the site won't let me use the formatting tools)
1 2 3 4 5 6
cActionPuppet::cActionPuppet(std::vector< std::unique_ptr<ActionMove> > _cache)
:cActor(),
mActionMoveCache(_cache)
{
}
The general idea is that vector mActionMove copies the contents of _cache. Here's the declaration in cActionPuppet.h:
1 2 3 4 5 6 7 8 9 10
class cActionPuppet
:public cActor
{
public :
cActionPuppet(std::vector< std::unique_ptr<ActionMove> > _cache);
void updateCurrent(float dt, sf::Time _time);
std::vector< std::unique_ptr<ActionMove> > mActionMoveCache;
};
VS' intellisense returns no errors, but upon compiling, I get this error:
"Error 1 error C2280: 'std::unique_ptr<ActionMove,std::default_delete<_Ty>>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)' :
attempting to reference a deleted function C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xmemory0
"
Thanks in advance.
Last edited on Jul 9, 2015 at 9:29pm UTC
Jul 9, 2015 at 10:00pm UTC
Simpler case: You want to make a copy of std::unique_ptr
object. Does unique_ptr have copy constructor or copy assignment? If not, why?
Jul 9, 2015 at 11:40pm UTC
I'm not trying to copy the ptr. I'm trying to copy the vector.
Jul 9, 2015 at 11:45pm UTC
A vector that contains unique_ptr elements.
Jul 9, 2015 at 11:52pm UTC
If I make a reference, then it would no longer copy the vector, which would go against what I'm attempting, here.
Last edited on Jul 9, 2015 at 11:53pm UTC