Const ref and rvalues again...
jerro
a at a.com
Thu Oct 18 17:02:59 PDT 2012
> 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.
More information about the Digitalmars-d
mailing list