Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2000-01-06 00:20:48


From: Dave Abrahams <abrahams_at_[hidden]>
> > 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.
>
> If you think hard about how triangle would be defined, I think you'll see
> that the issue doesn't really apply to that case.
>

You are right, it was an unappropriate example ;) Indeed, if we would want
to support some invariant (e.g. vertexes must be sorted in the clock-wise
order) on an internal implementation of triangle (assuming what we would use
'point' class for this implementation), we would swap whole points, but not
a separate coordinate values, as it happens with rectangle. But I think
*there are* good examples for this issue.

What are you think about following (potential) members of units_pair class:

void swap_x( self& other ) { std::swap( x_, other.x_ ); }
void swap_y( self& other ) { std::swap( y_, other.y_ ); }

??

-Alexy


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