You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$(P The argument is a type. If it is a struct with a copy constructor, returns $(D true). Otherwise, return $(D false). Note that a copy constructor is distinct from a postblit.
412
+
$(P The argument is a type.
413
+
If it is a struct with a copy constructor, returns $(D true). Otherwise, return $(D false).
414
+
A copy constructor is distinct from a move constructor or a postblit.
412
415
)
413
416
414
417
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
415
418
---
416
419
417
420
import std.stdio;
418
421
419
-
struct S
420
-
{
421
-
}
422
+
struct S { }
422
423
423
-
class C
424
-
{
425
-
}
424
+
class C { }
426
425
427
426
struct P
428
427
{
429
-
this(ref P rhs) {}
428
+
this(ref P rhs) {} // copy constructor
430
429
}
431
430
432
431
struct B
433
432
{
434
-
this(this) {}
433
+
this(this) {} // postblit
435
434
}
436
435
437
436
void main()
@@ -444,6 +443,45 @@ void main()
444
443
---
445
444
)
446
445
446
+
$(H3 $(GNAME hasMoveConstructor))
447
+
448
+
$(P The argument is a type.
449
+
If it is a struct with a move constructor, returns $(D true). Otherwise, return $(D false).
450
+
A move constructor is distinct from a copy constructor or a postblit.
writeln(__traits(hasMoveConstructor, B)); // false, this is a postblit
481
+
}
482
+
---
483
+
)
484
+
447
485
$(H3 $(GNAME hasPostblit))
448
486
449
487
$(P The argument is a type. If it is a struct with a postblit, returns $(D true). Otherwise, return $(D false). Note a postblit is distinct from a copy constructor.
0 commit comments