Re: [boost] Geometry/Vector Lib

In-Reply-To: <20060921173331.GJ14139@lie.Stanford.EDU> irving@cs.stanford.edu (Geoffrey Irving) wrote (abridged):
You probably meant "&x+2" in the first assert. I agree if that assert passes the code probably works, but I don't think the assert is guaranteed to pass. Personally I don't think code like that belongs in Boost; Boost ought to be exemplary. I'd prefer: template<class T> class vector3 { T base[3]; public: T& operator[](unsigned i) { assert(i<3); return base[i]; } T& x() { return base[0]; } T& y() { return base[1]; } T& z() { return base[2]; } }; with no public variables. The encapsulation is worth the extra brackets. (Actually I'd rather use v.set_x(3) than v.x() = 3.) -- Dave Harris, Nottingham, UK.
participants (1)
-
brangdon@cix.compulink.co.uk