jeudi 7 septembre 2017

Where does the standard define the order of preference for binding of values to references?

As it is explained here, values of different categories bind to references of different kinds according to the following order of preference:

struct s {};

void f (      s&);  // #1
void f (const s&);  // #2
void f (      s&&); // #3
void f (const s&&); // #4

const s g ();
s x;
const s cx;

f (s ()); // rvalue        #3, #4, #2
f (g ()); // const rvalue  #4, #2
f (x);    // lvalue        #1, #2
f (cx);   // const lvalue  #2

Where in the standard is this order of preference described?

Aucun commentaire:

Enregistrer un commentaire