ich den aktuellen Konstruktor in meinem Device.cppImplementierung bewegen Konstruktor und Zuordnung mit unique_ptr <>
Device::Device(const char *devName)
{
device = devName;
bt.reset(BTSerialPortBinding::Create(devName, 1));
}
Meine Device.h Datei haben enthält eine Klasse Gerät mit:
Device(const char *devName="");
~Device();
const char *device;
std::unique_ptr<BTSerialPortBinding> bt;
ich versuche Einen Move-Konstruktor zu rich- ten und die Zuweisung als unique_ptr zu verschieben, ist nicht kopierbar, so dass meine Klasse nicht kopierbar ist und die ~ Device() sie schließlich löscht.
Daher, wenn ich versuche zu verwenden:
Device dev; // declared in Process.h
dev = Device("93:11:22"); // initialised in Process.cpp
Ich erhalte die folgende Fehlermeldung:
Device &Device::operator =(const Device &)': attempting to reference a deleted function
Ich habe versucht, die folgenden ohne Glück in Device.h:
//move assignment operator
Device &operator=(Device &&o)
{
if (this != &o)
{
bt = std::move(o.bt);
}
return *this;
}
Device(Device &&o) : bt(std::move(o.bt)) {};
Ich bekomme diese Fehler, wenn ich dies versuche:
1>bluetoothserialport.lib(BTSerialPortBinding.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in ArduinoDevice.obj
1>bluetoothserialport.lib(BluetoothHelpers.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in ArduinoDevice.obj
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" ([email protected]@@[email protected]@Z) already defined in libcpmtd.lib(xlock.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" ([email protected]@@[email protected]) already defined in libcpmtd.lib(xlock.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" ([email protected]@@[email protected]) already defined in libcpmtd.lib(stdthrow.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "void __cdecl std::_Xbad_alloc(void)" ([email protected]@@YAXXZ) already defined in libcpmtd.lib(xthrow.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" ([email protected]@@[email protected]) already defined in libcpmtd.lib(xthrow.obj)
1>msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "void __cdecl std::_Xout_of_range(char const *)" ([email protected]@@[email protected]) already defined in libcpmtd.lib(xthrow.obj)
Rennen in Windows 10 auf Visual Studio 2015 mit dieser Bibliothek für BTSerialPortBinding: https://github.com/Agamnentzar/bluetooth-serial-port
Wo ist dein [MCVE]? –