Boost logo

Boost :

From: Dave Harris (brangdon_at_[hidden])
Date: 2006-10-06 16:38:33


In-Reply-To: <eg3csg$jm9$1_at_[hidden]>
andy_at_[hidden] (Andy Little) wrote (abridged):
> Why not :
>
> at_x(vec)

If we don't mind the syntactic clutter of the function call, we can use
vec.x().

   double vector::x() const { return data[0]; }
   double vector::y() const { return data[1]; }

This ought to have the runtime efficiency of vec.x while still hiding the
internal representation, and supporting indexed access without undefined
behaviour. The only argument I can see against it is that some people
don't want to have to type the brackets.

-- Dave Harris, Nottingham, UK.


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