A
Asfand Yar Qazi
Hi,
I've got this class, you see:
class Vec4
{
Vec4();
...
float data[4];
float& x;
float& y;
float& z;
float& w;
...
};
Vec4::Vec4()
: x(data[0]), y(data[1]), z(data[2]), w(data[3])
{
}
So, in code I can do a:
// yes, I know the - is there
Vec4 v = some_stuff + some-other_stuff;
// The following two should be identical
dostuff(v[0]);
dostuff(v.x);
Obviously, this is convenient for me, and increases readability. But
is it something that you would consider ok, no-so-good, or just plain
evil? Would this be portable?
Thanks,
Asfand Yar
I've got this class, you see:
class Vec4
{
Vec4();
...
float data[4];
float& x;
float& y;
float& z;
float& w;
...
};
Vec4::Vec4()
: x(data[0]), y(data[1]), z(data[2]), w(data[3])
{
}
So, in code I can do a:
// yes, I know the - is there
Vec4 v = some_stuff + some-other_stuff;
// The following two should be identical
dostuff(v[0]);
dostuff(v.x);
Obviously, this is convenient for me, and increases readability. But
is it something that you would consider ok, no-so-good, or just plain
evil? Would this be portable?
Thanks,
Asfand Yar