Enum member std.traits.hasElaborateAssign
True if S
or any type directly embedded in the representation of S
defines an elaborate assignment. Elaborate assignments are introduced by
defining opAssign(typeof(this))
or opAssign(ref typeof(this))
for a struct
or when there is a compiler-generated opAssign
.
enum hasElaborateAssign(S)
= hasElaborateAssign!(typeof(S .init[0]));
A type S
gets compiler-generated opAssign
if it has
an elaborate destructor.
Classes and unions never have elaborate assignments.
Note
Structs with (possibly nested) postblit operator(s) will have a hidden yet elaborate compiler generated assignment operator (unless explicitly disabled).
Example
static assert(!hasElaborateAssign!int);
static struct S { void opAssign(S) {} }
static assert( hasElaborateAssign!S);
static assert(!hasElaborateAssign!(const(S)));
static struct S1 { void opAssign(ref S1) {} }
static struct S2 { void opAssign(int) {} }
static struct S3 { S s; }
static assert( hasElaborateAssign!S1);
static assert(!hasElaborateAssign!S2);
static assert( hasElaborateAssign!S3);
static assert( hasElaborateAssign!(S3[1]));
static assert(!hasElaborateAssign!(S3[0]));
Authors
Walter Bright,
Tomasz Stachowiak (isExpressions
),
Andrei Alexandrescu,
Shin Fujishiro,
Robert Clipsham,
David Nadlinger,
Kenji Hara,
Shoichi Kato