My question is simple
#include <iostream>
using namespace std;
template <typename T>
void f(T&& i) {
cout << i << endl;
}
void g(int&& i) {
cout << i << endl;
}
int main() {
int i = 0;
f(i); // works fine
g(i); // candidate function not viable: no known conversion from 'int' to 'int &&'
// for 1st argument void g(int&& i)
}
Why can I pass an lvalue to templated function f()
but not non templated function g()