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.

Module dmd.clone

Builds struct member functions if needed and not defined by the user. Includes opEquals, opAssign, post blit, copy constructor and destructor.

Documentation

https://dlang.org/phobos/dmd_clone.html

Coverage

https://codecov.io/gh/dlang/dmd/src/master/src/dmd/clone.d

Functions

NameDescription
buildCopyCtor(sd, sc) Generates a copy constructor if needCopyCtor() returns true. The generated copy constructor will be of the form: this(ref return scope inout(S) rhs) inout { this.field1 = rhs.field1; this.field2 = rhs.field2; ... }
buildDtor(ad, sc) Create inclusive destructor for struct/class by aggregating all the destructors in dtors[] with the destructors for all the members.
buildExternDDtor(ad, sc) build a shim function around the compound dtor that translates a C++ destructor to a destructor with extern(D) calling convention
buildInv(ad, sc) Create inclusive invariant for struct/class by aggregating all the invariants in invs[].
buildOpAssign(sd, sc) Build opAssign for a struct.
buildOpEquals(sd, sc) Build opEquals for struct. const bool opEquals(const S s) { ... }
buildPostBlit(sd, sc) Create inclusive postblit for struct by aggregating all the postblits in postblits[] with the postblits for all the members. Note the close similarity with AggregateDeclaration::buildDtor(), and the ordering changes (runs forward instead of backwards).
buildXopCmp(sd, sc) Build _xopCmp for TypeInfo_Struct static bool _xopCmp(ref const S p, ref const S q) { return p.opCmp(q); }
buildXopEquals(sd, sc) Build _xopEquals for TypeInfo_Struct static bool _xopEquals(ref const S p, ref const S q) { return p == q; }
buildXtoHash(sd, sc) Build _xtoHash for non-bitwise hashing static hash_t xtoHash(ref const S p) nothrow @trusted;
hasIdentityOpAssign(ad, sc) Check given aggregate actually has an identity opAssign or not.
mergeFuncAttrs(s1, f) Merge function attributes pure, nothrow, @safe, @nogc, and @disable from f into s1.
needOpEquals(sd) We need an opEquals for the struct if any fields has an opEquals. Generate one if a user-specified one does not exist.

Authors

Walter Bright

License

Boost License 1.0