Boost logo

Boost :

From: Olivier Grant (olivier.grant_at_[hidden])
Date: 2006-09-21 08:39:45


ok, what about this ?

class vector3d_test
{
public:
    float x, y, z;

    float operator[]( int index ) const
    { return array[index]; }

    float & operator[]( int index )
    { return array[index]; }

    union
    {
        struct
        {
            float x;
            float y;
            float z;
        } coord;
        float array[3];
    };
};

but it means you have to call v.coord.x and v[0].

Olivier.

On 9/21/06, me22 <me22.ca_at_[hidden]> wrote:
>
> On 9/21/06, Olivier Grant <olivier.grant_at_[hidden]> wrote:
> > in which case "v.x" and "v[0]" are the same thing. this is what I
> currently
> > have. Now some people will argument its a hack maybe.
> >
> Sure looks like illegal type punning to me...
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk