M
mojmir
hello,
i've just encountered following piece of code:
struct Vector
{
float x, y, z;
inline float & operator[] (size_t i)
{
assert(i<3);
return *(&x + i);
}
};
i think it can work due to placement in memory, but i'd like to ask
you
whether it is a good and safe programming practice or not.
many thanks in advance,
mojmir
i've just encountered following piece of code:
struct Vector
{
float x, y, z;
inline float & operator[] (size_t i)
{
assert(i<3);
return *(&x + i);
}
};
i think it can work due to placement in memory, but i'd like to ask
you
whether it is a good and safe programming practice or not.
many thanks in advance,
mojmir