View source code
Display the source code in dmd/clone.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function dmd.clone.buildOpAssign
Build opAssign for struct. ref S opAssign(S s) { ... }
Note that s
will be constructed onto the stack, and probably
copy-constructed in caller site.
If S has copy copy construction and/or destructor, the body will make bit-wise object swap: S _swap = this; // bit copy this = s; // bit copy _swap.dtor(); Instead of running the destructor on s, run it on tmp instead.
Otherwise, the body will make member-wise assignments: Then, the body is: this.field1 = s.field1; this.field2 = s.field2; ...;
References
https
//dlang.org/spec/struct.html#assign-overload
Parameters
Name | Description |
---|---|
sd | struct to generate opAssign for |
sc | context |
Returns
generated opAssign function
Authors
License
Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.