Boost logo

Boost :

From: Sylvain Pion (pion_at_[hidden])
Date: 2002-09-06 13:56:02


On Fri, Sep 06, 2002 at 06:58:44PM +0200, Gabriel Dos Reis wrote:
> | > | Do you use std::complex just to store a pair of floats ? No.
> | >
> | > Yes.
> | >
> | > As coordinates of point in the Euclidian plane. I get scalar product
> | > and determinant for free.
> |
> | You missed the "just" in my sentence.
>
> No, I didn't.

Good.

> | If you get the scalar product, it's not "just to store" anymore.
>
> Obviously, storing "just" a data isn't interesting it itself. Is it?

It is not, indeed, and this is exactly my point.
My view for the "just using to store" is that it is the largest common
denominator of all reasonnable usages of complex.

For your application, you used std::complex because it made sense to use
complex as a good tool for doing a few things on 2D points. But the
lexicographical order on cartesian coordinates (which is a reasonnable total
order commonly used in computational geometry when you deal with cartesian
coordinates) that you used for your std::map was related to _this_ particular
use of complex. And another use of complex might have a better, different
order which corresponds to the nature of its usage of complex.

Think at a little higher level of abstraction : think that complex could be
represented in polar coordinates. The lexicographical order on the cartesian
coordinates would not make any sense for a different application that your
mapping of points ! Because if it's just for key-mapping, you are obviously
going to use the lexicographical order on the 2 polar coordinates directly.

And this is probably the reason why there's no default lexicographic order (or
any other) for std::complex : there's no "true one" order corresponding to the
nature (and only basic nature) of complex numbers.

Maybe I'm talking non-sense, but this is how I view this _default_ order
problem.

> | > | So I am still on the position that there should either be no default
> | > | Comparison_policy,
> | >
> | > Well, if the argument is that you don't want the default, then just don't
> | > use it.
> |
> | A default should have a justification that it's generally useful, more than
> | other possibilities.
>
> Weren't justifications for having the proposed default given I would
> say "you may have a point." However, I did find convicing arguments
> made for having the proposed default.

My counter argument is still that such an order (suitable as default for some
STL stuff), if it existed, should be related to the inherent nature of
intervals, and not tight to a particular domain.

Also, think that another suitable representation of intervals is :
(central approximation, epsilon). The lexicographical order on (lower, upper)
becomes non-sense for that representation.

So the lexicographical order :
- is coupled to a particular representation.
- is not suitable as operator< (and we discussed the default order must be the
  same as std::less) for almost all applications of IA.

> | Otherwise, why this one and not another one ?
>
> Do you want me to repeat all the messages sent on the topic?

Nope, thanks :)

-- 
Sylvain

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