Accessing non-array floats via pointers
<p>Is this valid/portable/legal code:</p>

<pre><code>class Vector3
{
public:

  float&amp; operator [] ( const size_t i )
  {
    assert( i &lt; 3 );

    return *(&amp;x+i);
  }

  float x, y, z;
};
</code></pre>

<p>There have been quite a few instances where I wanted to use the <code>[]</code> operator and ended up putting the elements in an array (to avoid if/switch statements). I never did what is being done in this particular method. I can tell why it works (x,y and z are contiguous) but is it good (or at least ok) practice?</p>

<p>Also, does the code require <code>#pragma pack 1</code> to guarantee no-pad packing or can it work without it? Reason I ask is because the snippet is actually taken from Ogre3D vector class and I don't see <code>#pragma pack 1</code> anywhere.</p>
