On Saturday, 1 June 2019 at 21:05:32 UTC, SrMordred wrote:
import std.traits;

struct T { this(ref return scope T other){} }
pragma(msg,  hasElaborateCopyConstructor!T); //false

hasElaborateCopyConstructor checks if the type defines a postblit[0]. That is, a function called this(this). this(T) is just a regular constructor, and as such does not qualify. From the documentation[1]:

Elaborate copy constructors are introduced by defining this(this) for a struct.


Postblits are called after assignment, on the instance being assigned to, and has no access to the source of the assignment. If you need access to the source, a ref constructor like yours will work.

--
  Simen

[0]: https://dlang.org/spec/struct.html#struct-postblit
[1]: https://dlang.org/library/std/traits/has_elaborate_copy_constructor.html

Reply via email to