The distinction between rvalue references and forwarding references was made clear enough in this example by Scott Meyers:
Widget&& var1 = someWidget; // here, “&&” means rvalue reference (1)
auto&& var2 = var1; // here, “&&” does not mean rvalue reference (2)
template<typename T>
void f(std::vector<T>&& param); // here, “&&” means rvalue reference (3)
template<typename T>
void f(T&& param); // here, “&&”does not mean rvalue reference (4)
Essentially the distinction happens when we have a deducible context, hence case (3) explicitly states that we have a vector<...>&&
whereas the T
in case (4) is to be deduced and (after applying reference collapsing rules) categorized in terms of "value category".
But what happens with a bit more complex pattern matching? Take the following case for example :
template <template <class...> class Tuple, class... Ts>
void f(Tuple<Ts...>&& arg)
{
}
What does &&
mean here ?
Aucun commentaire:
Enregistrer un commentaire