3 ms·
Maybe you're confusing reference collapsing with universal references? In your example, replace bar<int&&>(6) to bar<int&&>(i). It won't compile because i is
by monk_the_dog 12y ago
Maybe you're confusing reference collapsing with universal references?
In your example, replace bar<int&&>(6) to bar<int&&>(i).
It won't compile because i is not an r value. bar(i) will compile, because the template parameter is a universal reverence that will become an lvalue (not an rvalue) through reference collapsing.
- splinterofchaos 12y agoI called "bar" with "<int&&>" to demonstrate that you can bind an rvalue-ref to an rvalue-ref, not to suggest that's how it should be called.