mercredi 30 mai 2018

can I use std::move with class that doesn't provide a move constructor?

I have a class like this:

class myClass
{
    int x[1000];
 public:
     int &getx(int i)
    {
        return x[i];
    }
}

Please note that I did not provide a move construct here.

if I use the following code:

myClass A;
auto B=std::move(a);

does A moves to B or since I did not provided a move constructor, A is copied to B?

Is there any default move constructor for an object? If yes, how it does work with pointers and dynamically allocated arrays?

Aucun commentaire:

Enregistrer un commentaire