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
Copy file name to clipboardExpand all lines: spec/traits.dd
+79Lines changed: 79 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,8 @@ $(GNAME TraitsKeyword):
47
47
$(GLINK isModule)
48
48
$(GLINK isPackage)
49
49
$(GLINK hasMember)
50
+
$(GLINK hasCopyConstructor)
51
+
$(GLINK hasPostblit)
50
52
$(GLINK identifier)
51
53
$(GLINK getAliasThis)
52
54
$(GLINK getAttributes)
@@ -664,6 +666,83 @@ void main()
664
666
---
665
667
)
666
668
669
+
$(H2 $(GNAME hasCopyConstructor))
670
+
671
+
$(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.
writeln(__traits(hasCopyConstructor, B)); // false, this is a postblit
703
+
}
704
+
---
705
+
)
706
+
707
+
$(H2 $(GNAME hasPostblit))
708
+
709
+
$(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.
710
+
)
711
+
712
+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
713
+
---
714
+
715
+
import std.stdio;
716
+
717
+
struct S
718
+
{
719
+
}
720
+
721
+
class C
722
+
{
723
+
}
724
+
725
+
struct P
726
+
{
727
+
this(ref P rhs) {}
728
+
}
729
+
730
+
struct B
731
+
{
732
+
this(this) {}
733
+
}
734
+
735
+
736
+
void main()
737
+
{
738
+
writeln(__traits(hasPostblit, S)); // false
739
+
writeln(__traits(hasPostblit, C)); // false
740
+
writeln(__traits(hasPostblit, P)); // false, this is a copy ctor
741
+
writeln(__traits(hasPostblit, B)); // true
742
+
}
743
+
---
744
+
)
745
+
667
746
$(H2 $(GNAME identifier))
668
747
669
748
$(P Takes one argument, a symbol. Returns the identifier
0 commit comments