Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-05-28 19:34:53


Peter Dimov wrote:
>
> From: "John Max Skaller" <skaller_at_[hidden]>
>
> > less<> was introduced _solely_ to provide
> > a total ordering on pointers, since < cannot be
> > relied upon to provide one. It is necessary
> > to create STL sets (etc) of pointers.
>
> Someone that knows the history of C++ better than me may correct me if I'm
> wrong, but I don't believe this is the case.
>
> The original STL had std::less that was not guaranteed to provide a total
> ordering on pointers. std::less was just a function object wrapper around
> operator<, just like std::plus is a wrapper around operator+.
>
> std::less was subsequently 'patched' to provide a total ordering because the
> alternative - imposing a total ordering requirement on operator< - was not
> practical.

        You're right. I think I was the one who first
proposed the patch. :-)
        
        So I should have said that the requirement that the implementor
provide total ordering semantics, using a partial specialisation
if necessary, was introduced to permit pointers being used in
containers.
The alternative (requiring < to provide a total order on pointers)
was considered too constraining. [E.g. performance issue for DOS]

-- 
John (Max) Skaller, mailto:skaller_at_[hidden]
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net

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