Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Vector(T, int dimension) if(__traits(isArithmetic, T))
- {
- static assert(dimension > 0, "Dimension must be positive and non-zero.");
- static if(dimension == 1)
- {
- public T X;
- this(T x)
- {
- X = x;
- }
- }
- else static if(dimension == 2)
- {
- public T X, Y;
- this(T x, T y)
- {
- X = x;
- Y = y;
- }
- }
- else static if(dimension == 3)
- {
- public T X, Y, Z;
- this(T x, T y, T z)
- {
- X = x;
- Y = y;
- Z = z;
- }
- }
- else static if(dimension == 4)
- {
- public T X, Y, Z, W;
- this(T x, T y, T z, T w)
- {
- X = x;
- Y = y;
- Z = z;
- W = w;
- }
- }
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement