mardi 24 janvier 2017

why rvalue reference choose to use && rather than a new symbol?

Why do rvalue references use && rather than a new symbol?

& is already used when taking the address of a variable, and declaring variable references, so why keep bloating the usage of this symbol instead of using a new symbol?

For example, use A# or A@ instead of A&&.

The benefit of introducing a new symbol:

  1. easy to read, as it stands out telling you that this is a new type.

  2. it doesn't have the problem of reference collapsing, such as &&& should be parsed as & && or && &?

Why does the C++ standard choose &&?

Aucun commentaire:

Enregistrer un commentaire