vendredi 20 avril 2018

Bind rvalue reference to lvalue with `void*`

While trying to understand how rvalue references work I ended up with this piece of code:

int* iptr = nullptr;
int*&& irr = iptr;

Compiling the above code gives the following error:

error: rvalue reference to type 'int *' cannot bind to lvalue of type 'int *'

I understand this is correct, but why does the following code, where I bind using a void* instead of int*, compiles without any problem? Will the runtime behavior be correct or should I expect undefined behavior?

int* iptr = nullptr;
void*&& irr = iptr;

Aucun commentaire:

Enregistrer un commentaire