xxxxxxxxxx
import std;
struct Point4 {
Tuple!(
float, "x",
float, "y",
float, "z",
float, "w"
) coords;
alias coords this;
this(float x, float y, float z, float w)
{
coords = tuple(x, y, z, w);
}
}
// check for no UB
static assert( Point4.sizeof == 16 );
void main() {
Point4 p = Point4(1, 2, 3, 4);
p[2].writeln;
assert( p[2] == p.z );
p[0] = 5;
assert(p.x == 5);
//p[5] = 0; // Error: array index [5] is outside array bounds [0 .. 4]
}