The problem with binding rvalues to const ref is that you could take and store the address of it. That's why I'd recommend using "in ref" instead.

You can also take and store the address of a local variable that was passed as a const ref parameter, and accessing it after the caller exits will result in undefined behavior too. On the other hand, addresses of both local variables and rvalues will be valid at least until the called function returns. Local variables and rvalues are equivalent in regard to this problem.

Reply via email to