Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-07-11 08:34:31


Guillaume Melquiond wrote:
> Le mardi 11 juillet 2006 à 14:21 +0300, Peter Dimov a écrit :
>
>>> Interesting. I would have chosen magnitude and then angle. Why
>>> components.
>>
>> There are two reasons for that. First, composite types use
>> lexicographical ordering by default, and std::complex is (de facto)
>> a (real, imag) pair. Second, the magnitude/angle ordering has the
>> property that if you have three numbers a, b, c, where a and b are
>> very close to one another but not to c, it is possible to have a < c
>> and c < b.
>
> Your reasoning is a bit flawed, since this property is also true for
> the lexicographic order.

Yes, you and Martin Bonner are right, and I am wrong on that.

>> complex<double>
>> struct { double x, double y; }
>> pair<double, double>
>> tuple<double, double>
>> vector<double>
>> vector<char>
>> string
>
> Any set of computer data can be ordered. I don't think it means that
> they should all have an operator<.

Yes of course. So which types should have an operator< and which should not?


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