Boost logo

Boost :

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

On Tue, Nov 25, 2014 at 7:33 PM, Edward Diener <eldiener_at_[hidden]>
> If the C++ standard says that associative container of std::optionals is
> fine but some programmers believe that manually comparing them via the less
> than operator is not fine, I think we have a real conceptual problem here,
> even outside of the mere non-orthogonality of the situation.

We already have this kind of thing in the standard. Consider pointer types.
You can use std::less with arbitrary pointers, but this is not the case
with operator< (though operator< is well defined when the objects pointed
to are in the same array).

Again, I'm not advocating leaving out operator< for optional, but if the
main reason why people want it is because it makes it easy to work with
associative containers, we already have precedent in the standard to allow
this and not operator<.

-Matt Calabrese

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