Я попробовал несколько вещей, но ничего не получилось, проверил операторы, но не смог найти ошибку.
Изначально он был создан с помощью Visual Studio 2008 и прекрасно компилируется там.
Но я должен построить его с помощью Visual Studio. 2019 и столкнулся с этой проблемой во время компиляции:
Код: Выделить всё
error C2280: 'Clustering::NewType::~NewType(void)': attempting to reference a deleted function
error C2280: with
error C2280: [
error C2280: T=ConsortiaRelationElem
error C2280: ]
Вот определение класса Clustering:< /p>
Код: Выделить всё
template
class Clustering
{
friend CPlayer;
public:
union NewType
{
struct
{
T _Ttype;
};
CPlayer* m_player;
};
NewType m_Data;
public:
Clustering(){};
Clustering(const T& _Ttype)
{
m_Data.m_player = NULL;
memcpy( &m_Data._Ttype, &_Ttype, sizeof(T) );
};
Clustering& operator=(const T& _Ttype)
{
m_Data.m_player = NULL;
memcpy(&m_Data._Ttype, &_Ttype, sizeof(T));
};
~Clustering() { };
};
Код: Выделить всё
warning C4624: 'Clustering::NewType': destructor was implicitly defined as deleted
warning C4624: with
warning C4624: [
warning C4624: T=ConsortiaRelationElem
warning C4624: ]
error C2280: 'Clustering::NewType::~NewType(void)': attempting to reference a deleted function
error C2280: with
error C2280: [
error C2280: T=ConsortiaRelationElem
error C2280: ]
message : 'Clustering::NewType::~NewType(void)': function was implicitly deleted because 'Clustering::NewType' has a variant data member 'Clustering::NewType::_Ttype' with a non-trivial destructor
- Полный код: https://shrib.com/#Woodrat5GwaRRM
- Полный результат сборки: https:// shrib.com/#Yaretzi3mo9xQ4
Подробнее здесь: https://stackoverflow.com/questions/702 ... d-function
Мобильная версия