1

How should I interpret the argument to a move constructor or move assignment operator?

The syntax is typename && name. (eg; myclass && inst)

Is this a "reference to a reference", ie; works like a pointer to a pointer after compilation?

Or should this be regarded as a completely new type, a "different type of reference", ie; works like a single pointer after compilation?

I hope that is clear as a question.

FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225

1 Answers1

2

It's an r-value reference.

Informally this means that it's a reference to something that normally appears on the right hand side of an assignment. Ostensibly that can seem contradictory. But it means that contents of such an instance can be grabbed without any ill-effects occurring. Programs can use this to prevent unnecessary object copies from being taken.

Anonymous temporaries are a good example of such things.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483