Example of the perils of binding rvalues to const ref
IgorStepanov via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 17 03:03:10 PDT 2014
BTW. About r-values:
void fun(S s)
{
fun2(s); //pass s by value.
}
Now, compiler inserts postblit call before func2 call and dtor
before end of fun. However, it is able to doesn't it, because
after fun2 call, s isn't used.
Thus, we can implement last postblit optimization:
If compiler want to insert postblit, and object is't used after
this postblit, compiler is able to doesn't generate postblit and
last dtor calls.
Is there limitation of this optimization?
It may 90 percent to solve a r-value ref task.
More information about the Digitalmars-d
mailing list