mardi 5 avril 2016

Error: C2280 Creating a vector of unique_ptr to Class

It seems that when using a unique_ptr in vector<unique_ptr<UserInterface>> I get an error stating:

Error 1 error C2280: 'std::unique_ptr<UserInterface,std::default_delete<_Ty>>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)' : attempting to reference a deleted function c:\pr...ude\xmemory0 593 1 Win32Project1

Seemingly, no configuration allows me to store [smart] pointers to the UserInterface class, which has a simple structure:

#define InterfaceContruct vector<unique_ptr<UserInterface>>

class UserInterfaceMgmt
{
public:
    UserInterfaceMgmt();
    ~UserInterfaceMgmt();

    InterfaceContruct Interface;

    void AddUIElement();
    void RemoveUIElement();
    void DrawInterface();
    void MoveElement();
private:
};

Even if no function is called, the error shows up (InterfaceContruct Interface; is instantiated) I tried putting the copy constructor in private but it persists.

The .cpp file is:

#include "stdafx.h"
#include "UserInterfaceMgmt.h"

UserInterfaceMgmt::UserInterfaceMgmt()
{
}

UserInterfaceMgmt::~UserInterfaceMgmt()
{
}

void UserInterfaceMgmt::DrawInterface(){
    for (UINT i = 0; i < Interface.size(); i++)
    {
        Interface[i]->Draw();
    }
}

Aucun commentaire:

Enregistrer un commentaire