In C++, a function f taking a single argument of type T could have five different signatures (if I am not missing others):
void f( T); // #0
void f( T&); // #1
void f(const T&); // #2
void f( T&&); // #3
void f(const T&&); // #4
What are the full rules that the compiler follows for selecting among (a subset of) these overloads?
I would like to be able to discern in particular the cases in which:
fis called on a variable declared as eitherT,T&,const T&,T&&,const T&&;fis called on the output of a function returning eitherT,T&,const T&,T&&,const T&&.
PS: I already found here a reasonably complete description of what happens without case #0, but I would like to learn what happens when you throw #0 into the mix.
Aucun commentaire:
Enregistrer un commentaire