isCopyable

Determines whether the type T is copyable.

Only structs can be not copyable if their postblit constructor or the postblit constructor of one of its fields is disabled, i.e. annotated with $(D_KEYWORD @disable).

enum bool isCopyable(T);

Return Value

true if T can be copied, false otherwise.

Examples

static struct S1
{
}
static struct S2
{
    this(this)
    {
    }
}
static struct S3
{
    @disable this(this);
}
static struct S4
{
    S3 s;
}
class C
{
}

static assert(isCopyable!S1);
static assert(isCopyable!S2);
static assert(!isCopyable!S3);
static assert(!isCopyable!S4);

static assert(isCopyable!C);
static assert(isCopyable!bool);

Meta