SHOW:
|
|
- or go back to the newest paste.
1 | struct Vector(int size, type) { | |
2 | union { | |
3 | struct { | |
4 | static if (size > 0) type x = 0; | |
5 | static if (size > 1) type y = 0; | |
6 | static if (size > 2) type z = 0; | |
7 | static if (size > 3) type w = 1; | |
8 | } | |
9 | // COMMENT this struct to fix the bug | |
10 | struct { | |
11 | static if (size > 0) type r; | |
12 | static if (size > 1) type g; | |
13 | static if (size > 2) type b; | |
14 | static if (size > 3) type a; | |
15 | } | |
16 | } | |
17 | } | |
18 | ||
19 | struct A { | |
20 | int n; | |
21 | Vector!(3, float) v; | |
22 | } | |
23 | ||
24 | void main() { | |
25 | Vector!(3, float) v; | |
26 | assert(v.x == 0, "v.x != 0"); | |
27 | assert(v.y == 0, "v.y != 0"); | |
28 | assert(v.z == 0, "v.z != 0"); | |
29 | - | A a = A(); // OR simply use: A a; |
29 | + | A a = A(); // OR simply use: A a; |
30 | - | assert(a.v.x == 0, "a.v.x != 0"); |
30 | + | assert(a.v.x == 0, "a.v.x != 0"); |
31 | assert(a.v.y == 0, "a.v.y != 0"); | |
32 | assert(a.v.z == 0, "a.v.z != 0"); | |
33 | } |