I'm reading the reference collapsing rules and I have a question: why if I pass a rvalue A to
template<typename T>
void foo(T&&);
T is deduced to be A?
e.g. if I pass std::string() to the function T is deduced to be std::string, why not std::string&&? It would have made more sense to me, what's the rationale behind deducing T to the type itself?
Aucun commentaire:
Enregistrer un commentaire