The type to check.
true if S can be copied. false otherwise.
1 struct S1 {} // Fine. Can be copied 2 struct S2 { this(this) {}} // Fine. Can be copied 3 struct S3 {@disable this(this); } // Not fine. Copying is disabled. 4 struct S4 {S3 s;} // Not fine. A field has copying disabled. 5 6 class C1 {} 7 8 static assert( isCopyable!S1); 9 static assert( isCopyable!S2); 10 static assert(!isCopyable!S3); 11 static assert(!isCopyable!S4); 12 13 static assert(isCopyable!C1); 14 static assert(isCopyable!int); 15 static assert(isCopyable!(int[]));
Determines whether the type S can be copied. If a type cannot be copied, then code such as MyStruct x; auto y = x; will fail to compile. Copying for structs can be disabled by using @disable this(this).