Can anyone please explain why this compiles and why does t
end up with type int&
?
#include <utility>
void f(int& r)
{
++r;
}
template <typename Fun, typename T>
void g(Fun fun, T&& t)
{
fun(std::forward<T>(t));
}
int main()
{
int i = 0;
g(f, i);
}
I see this on GCC 4.5.0 20100604 and GDB 7.2-60.2