-
-
Notifications
You must be signed in to change notification settings - Fork 593
/
xpostblit.d
77 lines (64 loc) · 1.27 KB
/
xpostblit.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// PERMUTE_ARGS:
struct Field
{
this(this) @safe @nogc pure nothrow {}
}
struct Counter
{
static size_t cnt;
this(this) @safe @nogc nothrow { ++cnt; }
}
struct Foo
{
this(this) @safe @nogc pure nothrow {}
Field field;
}
void test1() @safe @nogc pure nothrow
{
Foo foo;
foo.__xpostblit();
}
static assert(__traits(hasMember, Foo, "__xpostblit"));
//
struct FieldPostblit
{
Counter counter;
}
struct AggrPostblit
{
static size_t cnt;
this(this) @safe @nogc nothrow { ++cnt; }
}
struct MixedPostblit
{
static size_t cnt;
Counter counter;
this(this) @safe @nogc nothrow { ++cnt; }
}
struct SNoPostblit {}
class CNoPostblit {}
static assert(!__traits(hasMember, SNoPostblit, "__xpostblit"));
static assert(!__traits(hasMember, CNoPostblit, "__xpostblit"));
void test2() @safe @nogc nothrow
{
FieldPostblit a;
assert(Counter.cnt == 0);
a.__xpostblit();
assert(Counter.cnt == 1);
AggrPostblit b;
assert(AggrPostblit.cnt == 0);
b.__xpostblit();
assert(AggrPostblit.cnt == 1);
Counter.cnt = 0;
MixedPostblit c;
assert(MixedPostblit.cnt == 0);
assert(Counter.cnt == 0);
c.__xpostblit();
assert(MixedPostblit.cnt == 1);
assert(Counter.cnt == 1);
}
void main()
{
test1();
test2();
}