[Issue 20733] New: Documentation for hasElaborateAssign says copy construction creates an opAssign

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 13 14:23:53 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20733

          Issue ID: 20733
           Summary: Documentation for hasElaborateAssign says copy
                    construction creates an opAssign
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ddoc
          Severity: trivial
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at yahoo.com

Documentation for hasElaborateAssign says:

   A type `S` gets compiler-generated `opAssign` in case it has
   an elaborate copy constructor or elaborate destructor.

In fact, having an elaborate copy constructor does not generate an opAssign:

---
import std.stdio;
import std.traits;

struct S
{
  this(ref const S other) { writeln("elaborate!"); }
}

void main()
{
   S s;
   writeln("copy construction:");
   S s2 = s;
   writeln("assignment:");
   s = s2;
   pragma(msg, __traits(allMembers, S));
   pragma(msg, hasElaborateAssign!S);
}
----
output:

-- compile time output
tuple("__ctor")
false

-- runtime output
copy construction:
elaborate!
assignment:

---


No opAssign as a member, no elaborate assignment appears to be happening, and
hasElaborateAssign is false.

The documentation should be changed.

--


More information about the Digitalmars-d-bugs mailing list