Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2000-01-05 20:42:25


Dave Abrahams (abrahams_at_[hidden]) wrote:

> > I've tried ;) But you can't do it with current interface of 'point' and
may
> > be this is a problem we need to solve some way. In order to restore
class
> > invariant you need to swap corresponding coordinates of rectangle edges
> > (e.g. left and right), not whole corner points. And the only form to
assign
> > a new value to any point coordinates (x or y) is to write something like
> > p.x( new_value ) - this is not a form with which std::swap can deal...
>
> On second thought, it's the implementation which is the problem, not the
> interface. You could store top, left, bottom, and right as separate data
> members instead of storing complete points.
>

Well, we can change implementation of rectangle (although I would not like
it - current version is pretty good except the above issue), but this will
not solve the problem with *point* class interface - when users of point
class will implement something like rectangle class (e.g., triangle), they
will run into the same problem of swapping coordinates of different point
objects.

-Alexy


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