www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20733] New: Documentation for hasElaborateAssign says copy

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 puremagic.com
          Reporter: schveiguy 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.

--
Apr 13