Hacker News new | ask | show | jobs
by monk_the_dog 4234 days 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.

1 comments

I 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.