Boost logo

Boost :

From: Anthony Williams (anthony.williamsNOSPAM_at_[hidden])
Date: 2002-11-18 04:49:25

Gennaro Prota writes:
> On 14 Nov 2002 12:40:38 +0000, Anthony Williams
> <anthony.williamsNOSPAM_at_[hidden]> wrote:
> >I have uploaded lexical_compare.hpp to the yahoo files area. It contains
> >implementations of the function template lexicalCompare.
> Just a little comment and a couple of questions. The former is
> actually just a matter of personal preference, so don't feel qualms
> about ignoring it (well, not that the same advice isn't valid for the
> questions too :-)

> BTW once you rewrite it as above you realize that you can
> further simplify it as:
> for (...) {
> if(*first1 < *first2)
> return -1;
> else if(*first2 < *first1)
> return +1;
> }
> if(first2 != last2) // (*)
> return -1;
> return first1 != last1;

I think it is clearer to explicitly return +1/0, rather than rely on the
conversion from true/false, but as you say, it is a matter of preference.

> The questions are: a) as you know the SGI STL has such a template for
> long time (lexicographical_compare_3way). Did you deliberately choose
> a different name? Why?

I wrote the function before I was aware of the SGI implementation.

> b) Did you really have problems without the
> casts?

They do no harm, and in the light of the recent discussions on the iterator
concept stress-test classes, I thought it better to put them in, given the
position I was arguing.


Anthony Williams
Senior Software Engineer, Beran Instruments Ltd.
Remove NOSPAM when replying, for timely response.

Boost list run by bdawes at, gregod at, cpdaniel at, john at