Boost logo

Boost :

Subject: Re: [boost] [optional] operator<(optional<T>, T) -- is it wrong?
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2014-11-30 20:31:30


On Sun, Nov 30, 2014 at 5:19 PM, Olaf van der Spek <ml_at_[hidden]> wrote:

> On Mon, Dec 1, 2014 at 1:58 AM, Matt Calabrese <rivorus_at_[hidden]> wrote:
> > Why? What makes the string default ordering "reasonable" and complex or
> > variant not? There are a lot of ways to order strings that might even be
> > more sensible in more cases than the current default (I.E. having
> different
>
> I think this kind of reasoning isn't very fruitful.
> Optional is not a string, string is not an optional. One having
> operator< does not imply the other should have it to.

Hmm? What isn't reasonable is arbitrarily deciding what should and should
not have a default ordering (not talking about operator< since that's a
much more controversial matter). The notion of default ordering is useful
because many datastructures and algorithms can make use of it, particularly
those in the standard. There is absolutely nothing wrong with ordering
tuples or optionals or variants, or any type at all. The only thing you
accomplish by not having a default ordering is that you arbitrarily make
the type difficult to use with these datastructures and algorithms. The
recommendation of "prefer unordered set" is already an example of the type
of poor programming advice that comes from this as a side effect.

-- 
-Matt Calabrese

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