Boost logo

Boost :

Subject: Re: [boost] [optional] Safe optional
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2014-11-24 13:16:12

On Thu, Nov 20, 2014 at 5:20 AM, Olaf van der Spek <ml_at_[hidden]> wrote:
> On Thu, Nov 20, 2014 at 11:00 AM, Andrzej Krzemienski
> <akrzemi1_at_[hidden]> wrote:
>>> > Note that the proposed expected<T, E> has the same "identity crisis":
>>> It'll probably face the same resistance.
>>> Comparing no value and a value simply doesn't make sense and code like
>>> shown is a real bug.
>> I disagree with this statement. In case of optional<T> having no value of T
>> is deliberately treated as a yet another value. This has a well defined
>> purpose. It is covered in the documentation here:
> By containers you specifically mean map, right?
> Unordered map for example would not require operator<
> Containers (maps) always come up as the primary rationale for operator<
> However, the user could also define his own comparison function for
> this purpose.

std::experimental::optional specializes std::less for exactly this
purpose. It could retain this specialization while at the same time
not support operator<.

(Or, to save std::less, introduce std::order, but that is another conversation)


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