Menu
Home
Create new Paste
Log in
Code
Theme: cobalt
Theme: eclipse
Theme: elegant
Theme: monokai
Theme: neat
Theme: night
Theme: rubyblue
struct S { char[] c; this(this) pure { c = c.dup; } auto opAssign(S other) pure { //blit other into this c = other.c; //call this(this) __postblit(); } } S foo(S s) pure { S other; other = s; return other; } void main() { //S s; //S another = foo(s); S s, another; s.c = ['a', 'b', 'c']; another = foo(s); destroy(s.c); assert(s.c == []); assert(another.c == ['a', 'b', 'c']); }
Result:
Success
/
Return code: 0
/
Compilation time:
0.119
seconds
/
Run time:
0.001
seconds
Disassembly
Username
Message
Add comment
Paste info
Author:
Guest
Views:
95
Private:
no
Expires:
Never
Uploaded:
02.12.12 15:10
Votes
:
0
Tweet
Compilation
Compiler:
DMD 2.x Gi
Pointer size:
m64
Actions
Download
Fork
Raw
×
Confirm
Are you sure you want to delete this paste?
There's no way back!
×
Confirm
Reason