www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12684] New: Allow posblit elision when passing arguments to


          Issue ID: 12684
           Summary: Allow posblit elision when passing arguments to
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: monarchdodra gmail.com

Similar to https://issues.dlang.org/show_bug.cgi?id=12683

Long story short:
void redirect(T)(T t)
    bar(t); //Postblit here
void bar(T)(T t);

Again, while I don't think we can elide the copy entirelly, I think we *can*
elide the postblit entirely.

Again, the reasons for allowing this are the same as 12683: There are *tons*
"redirect" functions that do nothing more than wrap a call to another
functions. The call to postblit is wasteful, and prevents usage with unique

Furthermore, this would be necessary for a more efficient "forward" template.
Currently, forward calls "T move(ref T t)". The "move" template in algorithm is
actually incredibly wasteful for types with postblits: It creates a 2
temporaries, it calls 2 memcopies, and it calls a destructor (on an object with
T.init state). *ALL* of this is exceedingly wasteful, for what should be
essentially be a no-op function...

Having this is necessary for fixing:
emplace does not work for rvalues

Apr 30 2014