C++ rvalue temporaries in template
- by aaa
hello.
Can you please explain me the difference between mechanism of the following:
int function();
template<class T>
void function2(T&);
void main() {
function2(function()); // compiler error, instantiated as int &
const int& v = function();
function2(v); // okay, instantiated as const int&
}
is my reasoning correct with respect to instantiation?
why is not first instantiated as const T&?
Thank you