Question about rvalue reference

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(int const& a, int const& b) {}
void accept(int& a, int& b) {}
void accept(int const& a, int& b) {}
void accept(int& a, int const& 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)

Thanks a lot
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.

Topic archived. No new replies allowed.