Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/core/internal/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,43 @@ template hasElaborateCopyConstructor(S)
}
else static if (is(S == struct))
{
enum hasElaborateCopyConstructor = __traits(hasMember, S, "__xpostblit");
enum hasElaborateCopyConstructor = __traits(hasCopyConstructor, S) || __traits(hasPostblit, S);
}
else
{
enum bool hasElaborateCopyConstructor = false;
}
}

@safe unittest
{
static struct S
{
int x;
this(return scope ref typeof(this) rhs) { }
this(int x, int y) {}
}

static assert(hasElaborateCopyConstructor!S);

static struct S2
{
int x;
this(int x, int y) {}
}

static assert(!hasElaborateCopyConstructor!S2);

static struct S3
{
int x;
this(return scope ref typeof(this) rhs, int x = 42) { }
this(int x, int y) {}
}

static assert(hasElaborateCopyConstructor!S3);
}

template hasElaborateAssign(S)
{
static if (__traits(isStaticArray, S) && S.length)
Expand Down