Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Vector(int size, type) {
- union {
- struct {
- static if (size > 0) type x = 0;
- static if (size > 1) type y = 0;
- static if (size > 2) type z = 0;
- static if (size > 3) type w = 1;
- }
- // COMMENT this struct to fix the bug
- struct {
- static if (size > 0) type r;
- static if (size > 1) type g;
- static if (size > 2) type b;
- static if (size > 3) type a;
- }
- }
- }
- struct A {
- int n;
- Vector!(3, float) v;
- }
- void main() {
- Vector!(3, float) v;
- assert(v.x == 0, "v.x != 0");
- assert(v.y == 0, "v.y != 0");
- assert(v.z == 0, "v.z != 0");
- A a = A(); // OR simply use: A a;
- assert(a.v.x == 0, "a.v.x != 0");
- assert(a.v.y == 0, "a.v.y != 0");
- assert(a.v.z == 0, "a.v.z != 0");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement