
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Martin Bonner Sent: Friday, September 22, 2006 6:52 AM To: boost@lists.boost.org Subject: Re: [boost] Geometry/Vector Lib
----Original Message---- From: Sohail Somani
Marcus Lindblom wrote:
I've sometimes done just:
class vector3d { public: float x, y, z;
float operator[]( int index ) const { return (&x)[index]; }
/* ... */ }; Won't that not work in the presence of padding?
In theory, yes. In practice, I can't see why any compiler would bother adding such padding.
Theory is what holds the C++ world together! I wouldn't want to knowingly invoke UB unless I can prove its worth my while (for example, in the case of hardware specific optimizations). Sohail