Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-05-28 05:32:22

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

Note that std::less_equal, for instance, is also guaranteed to provide a
total ordering for pointers, despite the fact that it does not define a
strict ordering, and hence, cannot be used with standard algorithms and
containers (as a comparison object).

Peter Dimov
Multi Media Ltd.

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