As I know, perfect forwarding is design for reducing the need of
many overloaded functions when you pass the reference to the function
and pass those reference to another functions
Besides, to fullfill the objective of perfect forwarding
&& should be able to swallow the lvalue and rvalue
That means I could write something like this
1 2 3 4 5 6 7 8 9 10 11 12
void accept(intconst& a, intconst& b) {}
void accept(int& a, int& b) {}
void accept(intconst& a, int& b) {}
void accept(int& a, intconst& b) {}
void testPF(int&& a, int&& b) {}
int main()
{
testPF(2, 3);//ok
int a = 10, b = 20;
testPF(a, b);//error
}
error message error: cannot bind 'int' lvalue to 'int&&'
my compilers : tdm gcc4.5.2
my os : windows xp sp3(32)
Sounds like a bug in the compiler to me. I would expect it to call version 2 since both a and b are (non-const) l-value references. But I've never used anything from C++0x yet.