+protected:
+ VectorComponents() { }
+
+public:
+ T &operator[](unsigned i) { return data[i]; }
+ const T &operator[](unsigned i) const { return data[i]; }
+};
+
+template<typename T>
+class VectorComponents<T, 2>
+{
+public:
+ T x, y;
+
+protected:
+ VectorComponents() { }
+
+public:
+ T &operator[](unsigned i) { return *(&x+i); }
+ const T &operator[](unsigned i) const { return *(&x+i); }
+};
+
+template<typename T>
+class VectorComponents<T, 3>
+{
+public:
+ T x, y, z;
+
+protected:
+ VectorComponents() { }
+
+public:
+ T &operator[](unsigned i) { return *(&x+i); }
+ const T &operator[](unsigned i) const { return *(&x+i); }
+};
+
+template<typename T>
+class VectorComponents<T, 4>
+{
+public:
+ T x, y, z, w;
+
+protected:
+ VectorComponents() { }
+
+public:
+ T &operator[](unsigned i) { return *(&x+i); }
+ const T &operator[](unsigned i) const { return *(&x+i); }
+};
+
+/**
+A general mathematical vector.
+*/
+template<typename T, unsigned N>
+class Vector: public VectorComponents<T, N>
+{