5 this(this) @safe @nogc pure nothrow {}
11 this(this) @safe @nogc nothrow { ++cnt
; }
16 this(this) @safe @nogc pure nothrow {}
20 void test1() @safe @nogc pure nothrow
26 static assert(__traits(hasMember
, Foo
, "__xpostblit"));
38 this(this) @safe @nogc nothrow { ++cnt
; }
45 this(this) @safe @nogc nothrow { ++cnt
; }
51 static assert(!__traits(hasMember
, SNoPostblit
, "__xpostblit"));
52 static assert(!__traits(hasMember
, CNoPostblit
, "__xpostblit"));
54 void test2() @safe @nogc nothrow
57 assert(Counter
.cnt
== 0);
59 assert(Counter
.cnt
== 1);
61 assert(AggrPostblit
.cnt
== 0);
63 assert(AggrPostblit
.cnt
== 1);
66 assert(MixedPostblit
.cnt
== 0);
67 assert(Counter
.cnt
== 0);
69 assert(MixedPostblit
.cnt
== 1);
70 assert(Counter
.cnt
== 1);
73 /****************************************************************
74 This test is intended to verify the exception safety of field
92 throw new Exception("");
96 ~this() { trace
~= name
~ ".dtor"; }
101 auto f1
= FieldThrow("f1");
102 FieldThrow
[2] f2f3
= [FieldThrow("f2"), FieldThrow("f3")];
103 auto f4
= FieldThrow("f4");
112 // Cause `s1.f4`'s postblit to throw
113 s1
.f4
.throwExcept
= true;
117 // `s`'s postblit will be a combination of `f1`, `f2f3`, and `f4`'s
118 // postblit in that order. However, `f4`'s postblit will throw,
119 // causing `s1.f2f3` and `s1.f1`'s destructors to execute in that
123 catch(Exception ex
){ }
125 // Confirm the field destructors were called and were called in the
127 assert(trace
== "f3.dtor" ~ "f2.dtor" ~ "f1.dtor");
129 /****************************************************************************/