I have the following class:
class BluetoothAddress
{
public:
BluetoothAddress();
BluetoothAddress(const unsigned char* address);
BluetoothAddress(const BluetoothAddress& bluetoothAddress);
~BluetoothAddress();
BluetoothAddress& operator=(const BluetoothAddress& other);
BluetoothAddress(BluetoothAddress&& other) = delete;
BluetoothAddress& operator=(BluetoothAddress&& other) = delete;
unsigned char address[BLUETOOTH_ADDRESS_LENGTH];
};
And the following function:
BluetoothAddress Create()
{
unsigned char addr = { 0x12, 0x34, 0x56, 0x78 0x9A, 0xBC };
return BluetoothAddress(addr);
}
I received this when I try to compile:
Error C2280 'BluetoothAddress::BluetoothAddress(BluetoothAddress &&)': attempting to reference a deleted function
I do not need a move constructor since there aren't any resources on the heap which need to be moved. (The constructor receiving the unsigned int*
is just copying the values in a loop char by char).
Why is the compiler trying to call the move constructor instead of the copy constructor?