Use of deleted function error when compiling
-
wrote on 7 Feb 2024, 04:28 last edited by Poldi 2 Jul 2024, 04:30
The following code does not compile as the compiler deletes the client decalartion because the default definition would be ill-formed
Client Header
#ifndef CLIENT_H #define CLIENT_H #include <QObject> class Client : public QObject { Q_OBJECT public: explicit Client(QObject *parent = nullptr); signals: }; #endif // CLIENT_H
Client Manager Header
#ifndef CLIENTMANAGER_H #define CLIENTMANAGER_H #include <QObject> #include <QTcpSocket> #include <QVector> #include "networkremote/client.h" class ClientManager : public QObject { Q_OBJECT public: explicit ClientManager(QObject *parent = nullptr); ~ClientManager(); void AddClient(QTcpSocket *socket); void RemoveClient(QTcpSocket *socket); private: QVector<Client> clients_; Client *client_ = nullptr; QTcpSocket *socket_ = nullptr; }; #endif // CLIENTMANAGER_H
Client Manager
#include "clientmanager.h" ClientManager::ClientManager(QObject *parent) : QObject{parent} { } ClientManager::~ClientManager() {} void ClientManager::AddClient(QTcpSocket *socket) { socket_ = socket; client_ = new Client; clients_.append(*client_); }
Copy of the log
15:07:38: Running steps for project strawberry... 15:07:38: Starting: "/home/llist/Qt/Tools/CMake/bin/cmake" --build /home/llist/sec1/git/build-myStrawberry-Desktop_Qt_6_6_1_GCC_64bit-Debug --target all [1/4 7.1/sec] Generating /home/llist/sec1/git/myStrawberry/src/translations/translations.pot [2/4 1.8/sec] Building CXX object src/CMakeFiles/strawberry_lib.dir/networkremote/clientmanager.cpp.o FAILED: src/CMakeFiles/strawberry_lib.dir/networkremote/clientmanager.cpp.o /usr/bin/ccache /usr/bin/x86_64-linux-gnu-g++ -DBOOST_BIND_NO_PLACEHOLDERS -DKDSINGLEAPPLICATION_STATIC_BUILD -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_CAST_TO_ASCII -DQT_NO_FOREACH -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_URL_CAST_FROM_STRING -DQT_SQL_LIB -DQT_STRICT_ITERATORS -DQT_USE_QSTRINGBUILDER -DQT_WIDGETS_LIB -I/home/llist/sec1/git/myStrawberry -I/home/llist/sec1/git/build-myStrawberry-Desktop_Qt_6_6_1_GCC_64bit-Debug -I/home/llist/sec1/git/build-myStrawberry-Desktop_Qt_6_6_1_GCC_64bit-Debug/src -I/home/llist/sec1/git/myStrawberry/src -I/home/llist/sec1/git/myStrawberry/ext/libstrawberry-common -I/home/llist/sec1/git/myStrawberry/ext/libstrawberry-tagreader -I/home/llist/sec1/git/build-myStrawberry-Desktop_Qt_6_6_1_GCC_64bit-Debug/ext/libstrawberry-tagreader -I/home/llist/sec1/git/myStrawberry/3rdparty/kdsingleapplication/KDSingleApplication/src -I/home/llist/sec1/git/myStrawberry/3rdparty/kdsingleapplication -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /usr/include/gstreamer-1.0 -isystem /usr/include/orc-0.4 -isystem /usr/include/libmount -isystem /usr/include/blkid -isystem /usr/include/gio-unix-2.0 -isystem /usr/include/gpod-1.0 -isystem /usr/include/gdk-pixbuf-2.0 -isystem /usr/include/libpng16 -isystem /usr/include/libusb-1.0 -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtCore -isystem /home/llist/Qt/6.6.1/gcc_64/include -isystem /home/llist/Qt/6.6.1/gcc_64/mkspecs/linux-g++ -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtConcurrent -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtGui -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtWidgets -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtNetwork -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtSql -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtDBus -DQT_QML_DEBUG -g -std=gnu++17 -fdiagnostics-color=always -std=c++17 -Wall -Wextra -Wpedantic -Wunused -Wshadow -Wundef -Wuninitialized -Wredundant-decls -Wcast-align -Winit-self -Wmissing-include-dirs -Wmissing-declarations -Wstrict-overflow=2 -Wunused-parameter -Wformat=2 -Wdisabled-optimization -Woverloaded-virtual -Wold-style-cast -fPIC -MD -MT src/CMakeFiles/strawberry_lib.dir/networkremote/clientmanager.cpp.o -MF src/CMakeFiles/strawberry_lib.dir/networkremote/clientmanager.cpp.o.d -o src/CMakeFiles/strawberry_lib.dir/networkremote/clientmanager.cpp.o -c /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp: In member function ‘void ClientManager::RemoveClient(QTcpSocket*)’: /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:23:46: warning: unused parameter ‘socket’ [-Wunused-parameter] 23 | void ClientManager::RemoveClient(QTcpSocket *socket) | ~~~~~~~~~~~~^~~~~~ In file included from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:7, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qbytearray.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstringview.h:8, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qchar.h:656, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstring.h:14, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/QObject:1, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:4, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h: In instantiation of ‘void QtPrivate::QGenericArrayOps<T>::emplace(qsizetype, Args&& ...) [with Args = {const Client&}; T = Client; qsizetype = long long int]’: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:877:15: required from ‘T& QList<T>::emplaceBack(Args&& ...) [with Args = {const Client&}; T = Client; QList<T>::reference = Client&]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:441:48: required from ‘void QList<T>::append(QList<T>::parameter_type) [with T = Client; QList<T>::parameter_type = const Client&]’ /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:17:18: required from here /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:581:17: error: use of deleted function ‘Client::Client(const Client&)’ 581 | new (this->end()) T(std::forward<Args>(args)...); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:7, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/sec1/git/myStrawberry/src/networkremote/client.h:6:7: note: ‘Client::Client(const Client&)’ is implicitly deleted because the default definition would be ill-formed: 6 | class Client : public QObject | ^~~~~~ /home/llist/sec1/git/myStrawberry/src/networkremote/client.h:6:7: error: use of deleted function ‘QObject::QObject(const QObject&)’ In file included from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qglobal.h:43, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qnamespace.h:12, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobjectdefs.h:12, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:10, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/QObject:1, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:4, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:353:5: note: declared here 353 | Q_DISABLE_COPY(QObject) | ^~~~~~~~~~~~~~ In file included from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:7, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qbytearray.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstringview.h:8, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qchar.h:656, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstring.h:14, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/QObject:1, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:4, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:586:17: error: use of deleted function ‘Client::Client(const Client&)’ 586 | new (this->begin() - 1) T(std::forward<Args>(args)...); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:592:11: error: use of deleted function ‘Client::Client(const Client&)’ 592 | T tmp(std::forward<Args>(args)...); | ^~~ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:600:13: error: use of deleted function ‘Client::Client(Client&&)’ 600 | new (this->begin() - 1) T(std::move(tmp)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:7, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/sec1/git/myStrawberry/src/networkremote/client.h:6:7: note: ‘Client::Client(Client&&)’ is implicitly deleted because the default definition would be ill-formed: 6 | class Client : public QObject | ^~~~~~ /home/llist/sec1/git/myStrawberry/src/networkremote/client.h:6:7: error: use of deleted function ‘QObject::QObject(const QObject&)’ In file included from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qglobal.h:43, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qnamespace.h:12, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobjectdefs.h:12, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:10, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/QObject:1, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:4, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:353:5: note: declared here 353 | Q_DISABLE_COPY(QObject) | ^~~~~~~~~~~~~~ In file included from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:7, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qbytearray.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstringview.h:8, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qchar.h:656, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstring.h:14, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/QObject:1, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:4, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h: In instantiation of ‘void QtPrivate::QGenericArrayOps<T>::copyAppend(const T*, const T*) [with T = Client]’: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:235:31: required from ‘void QArrayDataPointer<T>::reallocateAndGrow(QArrayData::GrowthPosition, qsizetype, QArrayDataPointer<T>*) [with T = Client; qsizetype = long long int]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:139:13: required from ‘void QArrayDataPointer<T>::detach(QArrayDataPointer<T>*) [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:409:29: required from ‘void QList<T>::detach() [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:609:22: required from ‘QList<T>::iterator QList<T>::end() [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:878:17: required from ‘T& QList<T>::emplaceBack(Args&& ...) [with Args = {const Client&}; T = Client; QList<T>::reference = Client&]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:441:48: required from ‘void QList<T>::append(QList<T>::parameter_type) [with T = Client; QList<T>::parameter_type = const Client&]’ /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:17:18: required from here /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:341:13: error: use of deleted function ‘Client::Client(const Client&)’ 341 | new (data + this->size) T(*b); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h: In instantiation of ‘void QtPrivate::QGenericArrayOps<T>::moveAppend(T*, T*) [with T = Client]’: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:237:31: required from ‘void QArrayDataPointer<T>::reallocateAndGrow(QArrayData::GrowthPosition, qsizetype, QArrayDataPointer<T>*) [with T = Client; qsizetype = long long int]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:139:13: required from ‘void QArrayDataPointer<T>::detach(QArrayDataPointer<T>*) [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:409:29: required from ‘void QList<T>::detach() [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:609:22: required from ‘QList<T>::iterator QList<T>::end() [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:878:17: required from ‘T& QList<T>::emplaceBack(Args&& ...) [with Args = {const Client&}; T = Client; QList<T>::reference = Client&]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:441:48: required from ‘void QList<T>::append(QList<T>::parameter_type) [with T = Client; QList<T>::parameter_type = const Client&]’ /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:17:18: required from here /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:373:13: error: use of deleted function ‘Client::Client(Client&&)’ 373 | new (data + this->size) T(std::move(*b)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ninja: build stopped: subcommand failed. 15:07:39: The process "/home/llist/Qt/Tools/CMake/bin/cmake" exited with code 1. Error while building/deploying project strawberry (kit: Desktop Qt 6.6.1 GCC 64bit) When executing step "Build" 15:07:39: Elapsed time: 00:01.
Thanks
-
The following code does not compile as the compiler deletes the client decalartion because the default definition would be ill-formed
Client Header
#ifndef CLIENT_H #define CLIENT_H #include <QObject> class Client : public QObject { Q_OBJECT public: explicit Client(QObject *parent = nullptr); signals: }; #endif // CLIENT_H
Client Manager Header
#ifndef CLIENTMANAGER_H #define CLIENTMANAGER_H #include <QObject> #include <QTcpSocket> #include <QVector> #include "networkremote/client.h" class ClientManager : public QObject { Q_OBJECT public: explicit ClientManager(QObject *parent = nullptr); ~ClientManager(); void AddClient(QTcpSocket *socket); void RemoveClient(QTcpSocket *socket); private: QVector<Client> clients_; Client *client_ = nullptr; QTcpSocket *socket_ = nullptr; }; #endif // CLIENTMANAGER_H
Client Manager
#include "clientmanager.h" ClientManager::ClientManager(QObject *parent) : QObject{parent} { } ClientManager::~ClientManager() {} void ClientManager::AddClient(QTcpSocket *socket) { socket_ = socket; client_ = new Client; clients_.append(*client_); }
Copy of the log
15:07:38: Running steps for project strawberry... 15:07:38: Starting: "/home/llist/Qt/Tools/CMake/bin/cmake" --build /home/llist/sec1/git/build-myStrawberry-Desktop_Qt_6_6_1_GCC_64bit-Debug --target all [1/4 7.1/sec] Generating /home/llist/sec1/git/myStrawberry/src/translations/translations.pot [2/4 1.8/sec] Building CXX object src/CMakeFiles/strawberry_lib.dir/networkremote/clientmanager.cpp.o FAILED: src/CMakeFiles/strawberry_lib.dir/networkremote/clientmanager.cpp.o /usr/bin/ccache /usr/bin/x86_64-linux-gnu-g++ -DBOOST_BIND_NO_PLACEHOLDERS -DKDSINGLEAPPLICATION_STATIC_BUILD -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_CAST_TO_ASCII -DQT_NO_FOREACH -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_URL_CAST_FROM_STRING -DQT_SQL_LIB -DQT_STRICT_ITERATORS -DQT_USE_QSTRINGBUILDER -DQT_WIDGETS_LIB -I/home/llist/sec1/git/myStrawberry -I/home/llist/sec1/git/build-myStrawberry-Desktop_Qt_6_6_1_GCC_64bit-Debug -I/home/llist/sec1/git/build-myStrawberry-Desktop_Qt_6_6_1_GCC_64bit-Debug/src -I/home/llist/sec1/git/myStrawberry/src -I/home/llist/sec1/git/myStrawberry/ext/libstrawberry-common -I/home/llist/sec1/git/myStrawberry/ext/libstrawberry-tagreader -I/home/llist/sec1/git/build-myStrawberry-Desktop_Qt_6_6_1_GCC_64bit-Debug/ext/libstrawberry-tagreader -I/home/llist/sec1/git/myStrawberry/3rdparty/kdsingleapplication/KDSingleApplication/src -I/home/llist/sec1/git/myStrawberry/3rdparty/kdsingleapplication -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /usr/include/gstreamer-1.0 -isystem /usr/include/orc-0.4 -isystem /usr/include/libmount -isystem /usr/include/blkid -isystem /usr/include/gio-unix-2.0 -isystem /usr/include/gpod-1.0 -isystem /usr/include/gdk-pixbuf-2.0 -isystem /usr/include/libpng16 -isystem /usr/include/libusb-1.0 -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtCore -isystem /home/llist/Qt/6.6.1/gcc_64/include -isystem /home/llist/Qt/6.6.1/gcc_64/mkspecs/linux-g++ -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtConcurrent -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtGui -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtWidgets -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtNetwork -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtSql -isystem /home/llist/Qt/6.6.1/gcc_64/include/QtDBus -DQT_QML_DEBUG -g -std=gnu++17 -fdiagnostics-color=always -std=c++17 -Wall -Wextra -Wpedantic -Wunused -Wshadow -Wundef -Wuninitialized -Wredundant-decls -Wcast-align -Winit-self -Wmissing-include-dirs -Wmissing-declarations -Wstrict-overflow=2 -Wunused-parameter -Wformat=2 -Wdisabled-optimization -Woverloaded-virtual -Wold-style-cast -fPIC -MD -MT src/CMakeFiles/strawberry_lib.dir/networkremote/clientmanager.cpp.o -MF src/CMakeFiles/strawberry_lib.dir/networkremote/clientmanager.cpp.o.d -o src/CMakeFiles/strawberry_lib.dir/networkremote/clientmanager.cpp.o -c /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp: In member function ‘void ClientManager::RemoveClient(QTcpSocket*)’: /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:23:46: warning: unused parameter ‘socket’ [-Wunused-parameter] 23 | void ClientManager::RemoveClient(QTcpSocket *socket) | ~~~~~~~~~~~~^~~~~~ In file included from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:7, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qbytearray.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstringview.h:8, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qchar.h:656, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstring.h:14, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/QObject:1, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:4, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h: In instantiation of ‘void QtPrivate::QGenericArrayOps<T>::emplace(qsizetype, Args&& ...) [with Args = {const Client&}; T = Client; qsizetype = long long int]’: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:877:15: required from ‘T& QList<T>::emplaceBack(Args&& ...) [with Args = {const Client&}; T = Client; QList<T>::reference = Client&]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:441:48: required from ‘void QList<T>::append(QList<T>::parameter_type) [with T = Client; QList<T>::parameter_type = const Client&]’ /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:17:18: required from here /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:581:17: error: use of deleted function ‘Client::Client(const Client&)’ 581 | new (this->end()) T(std::forward<Args>(args)...); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:7, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/sec1/git/myStrawberry/src/networkremote/client.h:6:7: note: ‘Client::Client(const Client&)’ is implicitly deleted because the default definition would be ill-formed: 6 | class Client : public QObject | ^~~~~~ /home/llist/sec1/git/myStrawberry/src/networkremote/client.h:6:7: error: use of deleted function ‘QObject::QObject(const QObject&)’ In file included from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qglobal.h:43, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qnamespace.h:12, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobjectdefs.h:12, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:10, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/QObject:1, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:4, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:353:5: note: declared here 353 | Q_DISABLE_COPY(QObject) | ^~~~~~~~~~~~~~ In file included from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:7, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qbytearray.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstringview.h:8, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qchar.h:656, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstring.h:14, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/QObject:1, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:4, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:586:17: error: use of deleted function ‘Client::Client(const Client&)’ 586 | new (this->begin() - 1) T(std::forward<Args>(args)...); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:592:11: error: use of deleted function ‘Client::Client(const Client&)’ 592 | T tmp(std::forward<Args>(args)...); | ^~~ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:600:13: error: use of deleted function ‘Client::Client(Client&&)’ 600 | new (this->begin() - 1) T(std::move(tmp)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:7, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/sec1/git/myStrawberry/src/networkremote/client.h:6:7: note: ‘Client::Client(Client&&)’ is implicitly deleted because the default definition would be ill-formed: 6 | class Client : public QObject | ^~~~~~ /home/llist/sec1/git/myStrawberry/src/networkremote/client.h:6:7: error: use of deleted function ‘QObject::QObject(const QObject&)’ In file included from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qglobal.h:43, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qnamespace.h:12, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobjectdefs.h:12, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:10, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/QObject:1, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:4, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:353:5: note: declared here 353 | Q_DISABLE_COPY(QObject) | ^~~~~~~~~~~~~~ In file included from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:7, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qbytearray.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstringview.h:8, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qchar.h:656, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qstring.h:14, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qobject.h:11, from /home/llist/Qt/6.6.1/gcc_64/include/QtCore/QObject:1, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.h:4, from /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:1: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h: In instantiation of ‘void QtPrivate::QGenericArrayOps<T>::copyAppend(const T*, const T*) [with T = Client]’: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:235:31: required from ‘void QArrayDataPointer<T>::reallocateAndGrow(QArrayData::GrowthPosition, qsizetype, QArrayDataPointer<T>*) [with T = Client; qsizetype = long long int]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:139:13: required from ‘void QArrayDataPointer<T>::detach(QArrayDataPointer<T>*) [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:409:29: required from ‘void QList<T>::detach() [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:609:22: required from ‘QList<T>::iterator QList<T>::end() [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:878:17: required from ‘T& QList<T>::emplaceBack(Args&& ...) [with Args = {const Client&}; T = Client; QList<T>::reference = Client&]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:441:48: required from ‘void QList<T>::append(QList<T>::parameter_type) [with T = Client; QList<T>::parameter_type = const Client&]’ /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:17:18: required from here /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:341:13: error: use of deleted function ‘Client::Client(const Client&)’ 341 | new (data + this->size) T(*b); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h: In instantiation of ‘void QtPrivate::QGenericArrayOps<T>::moveAppend(T*, T*) [with T = Client]’: /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:237:31: required from ‘void QArrayDataPointer<T>::reallocateAndGrow(QArrayData::GrowthPosition, qsizetype, QArrayDataPointer<T>*) [with T = Client; qsizetype = long long int]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydatapointer.h:139:13: required from ‘void QArrayDataPointer<T>::detach(QArrayDataPointer<T>*) [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:409:29: required from ‘void QList<T>::detach() [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:609:22: required from ‘QList<T>::iterator QList<T>::end() [with T = Client]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:878:17: required from ‘T& QList<T>::emplaceBack(Args&& ...) [with Args = {const Client&}; T = Client; QList<T>::reference = Client&]’ /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qlist.h:441:48: required from ‘void QList<T>::append(QList<T>::parameter_type) [with T = Client; QList<T>::parameter_type = const Client&]’ /home/llist/sec1/git/myStrawberry/src/networkremote/clientmanager.cpp:17:18: required from here /home/llist/Qt/6.6.1/gcc_64/include/QtCore/qarraydataops.h:373:13: error: use of deleted function ‘Client::Client(Client&&)’ 373 | new (data + this->size) T(std::move(*b)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ninja: build stopped: subcommand failed. 15:07:39: The process "/home/llist/Qt/Tools/CMake/bin/cmake" exited with code 1. Error while building/deploying project strawberry (kit: Desktop Qt 6.6.1 GCC 64bit) When executing step "Build" 15:07:39: Elapsed time: 00:01.
Thanks
wrote on 7 Feb 2024, 05:13 last edited by@Poldi said in Use of deleted function error when compiling:
The following code does not compile as the compiler deletes the client decalartion because the default definition would be ill-formed
clients_
needs to be an array of pointers not objects.
You cannot copy a QObject by design.The copy constructor is disabled by the:
353 | Q_DISABLE_COPY(QObject)
line you see in the error output.
-
@Poldi said in Use of deleted function error when compiling:
The following code does not compile as the compiler deletes the client decalartion because the default definition would be ill-formed
clients_
needs to be an array of pointers not objects.
You cannot copy a QObject by design.The copy constructor is disabled by the:
353 | Q_DISABLE_COPY(QObject)
line you see in the error output.
-
1/3