lundi 24 août 2020

Why is const template parameter not a universal/forwarding reference

I'm reading about universal references/forwarding references and this link says that:

Here param is a universal reference:

template<typename T>
void f(T&& param);   

But here param is not a universal reference, it is an rvalue reference:

template<typename T>
void f(const T&& param);

The definition for universal references is given as:

If a variable or parameter is declared to have type T&& for some deduced type T, that variable or parameter is a universal reference.

And I've read that T is a deduced type because of Template argument deduction.

Why is the second case not a universal reference? Does the presence of const T&& param not follow Template Argument Deduction, for some reason? If so, why?

Aucun commentaire:

Enregistrer un commentaire