Let us suggest I have a class called vec4. Its a template and could be uint8, float or int in most cases. Other cases are allowed but are less likely. The class looks like this:
template<class T>
class vec4 {
public:
vec4(){}
virtual ~vec4(){}
union {
struct {
T x,y,z,w;
};
struct {
T r,g,b,a;
};
};
};
This helps me think about a problem in different ways when writing code and allows me to do other cool things also and I rather enjoy the design pattern when ever applicable.
The problem is I would like to extend the class and add functions in the case it is a 32 bit float. That I can do. I would also like to extend the union for a further maths paradigm where the third members are T c,y,m,k.
I am finding it very difficult to find material on the subject.
Aucun commentaire:
Enregistrer un commentaire