[Issue 5546] Assigning and initializing structs from functions make more copies than necessary

2015-12-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=5546

Infiltrator  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||lt.infiltra...@gmail.com
 Resolution|--- |WORKSFORME

--- Comment #3 from Infiltrator  ---
2.069 produces the desired output:


Creating temp
Creating copy
Forwarding copy
Returning global
Copying global
Deleting global
Deleting copy
Deleting temp


--


[Issue 5546] Assigning and initializing structs from functions make more copies than necessary

2011-02-08 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5546



--- Comment #2 from akb...@gmail.com 2011-02-08 00:42:20 PST ---
After thinking about the problem a bit more, I have a couple things to add.

First, I should mention my second point for assigning the return value of a
function to an existing struct applies to all temporaries.

Test testVal;
testVal = Test(str);

can benefit from the same optimizations as

Test testVal;
testVal = function();

Second, it would be very useful to be able to mark the custom assignment
operator to have the same behavior on the above two cases as if there is no
overloaded assignment operator. (aka: skip the assignment and reduce it to a
blit + post blit and destruction of the old value when assigning from a
temporary) I would suggest something like putting @ignoreIfTemp before the
opAssign definition, and would be ignored if members of the struct have custom
assignment operators without that property. This would allow one of the most
useful benefits of rvalue references from C++0x to be used without having to
add a whole new type qualifier.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5546] Assigning and initializing structs from functions make more copies than necessary

2011-02-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5546



--- Comment #1 from akb...@gmail.com 2011-02-07 23:32:33 PST ---
Created an attachment (id=901)
Source file that demonstrates the behavior.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---