everyone. We have a problem In the past, we have designed some mathematics classes used in graphics in VS2008 Using union to implement data synonyms, for example
class CMatrix4FLOAT {
public:
union{
struct { float m_Buffer[16]; };
struct { float _M00, _M10, _M20, _M30,
_M01, _M11, _M21, _M31,
_M02, _M12, _M22, _M32,
_M03, _M13, _M23, _M33; };
}
...
...
};
Or
class CVectorReference4FLOAT {
public:
union{
struct { float &m_x, &m_y, &m_z, &m_w; };
struct { float &m_s, &m_t, &m_p, &m_q; };
struct { float &m_r, &m_g, &m_b, &m_a; };
}
....
CVectorReference4FLOAT(float * Array):
m_x(Array[0]), m_y(Array[1]), m_z(Array[2]), m_z(Array[3]),
m_s(Array[0]), m_t(Array[1]), m_p(Array[2]), m_q(Array[3]),
m_r(Array[0]), m_g(Array[1]), m_b(Array[2]), m_a(Array[3])
{}
};
ex:
float Buffer[4];
CVectorReference4FLOAT P0(Buffer);
P0.m_x = 3.5f;
CVectorReference4FLOAT Color(Buffer);
Color.m_r = 0.7f;
CMatrix4f MatrixLookAt;
CVectorReference3FLOAT AxisX = MatrixLookAt.GetColumnVector(0);
However, we are not allowed to use references in union after vs2015, which causes us some problems. We cannot use different names to represent the same data, or we need to take a little risk to change back to using point?