Boost logo

Boost :

Subject: Re: [boost] [optional] operator<(optional<T>, T) -- is it wrong?
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2014-11-27 15:52:13


2014-11-27 21:35 GMT+01:00 Vladimir Batov <Vladimir.Batov_at_[hidden]>
:

> On 11/28/2014 12:22 AM, Andrzej Krzemienski wrote:
>
>> ... Technically, the behavior of op<(optional<T>,T) is well-defined and
>> consistent with the conceptual model of optional. However, every practical
>> use case I have seen so far is a programmer bug.
>>
>
> I personally have to disagree with the statement... I find your readiness
> to immediately promote T to optional<T> unreasonable.

It is not *my* (human's) readiness to promote T to optional<T> everywhere.
This is simply a consequence of providing the converting constructor. The
message sent by declaring the converting constructor (the way I understand
converting ctors) is that T can be used *everywhere* where optional<T> is
required. Even in the places where someone may not like that.

> If you have that functionality, it does not mean you apply it it left and
> right and think it's the right thing to do.

If there was no converting constructor but only some make_optional(), I
would agree. But because we have the converting constructor, "the
functionality" is automatically applied everywhere. (At least this is my
understanding of the purpose of converting ctors). Optional is abusing the
converting syntax a bit. The conversion is loss-less, but with a slight
semantic change.

The behavior you actually described as "well-defined" is of
> op<(optional<T>, optional<T>)... the behavior of which is indeed
> well-defined... even though where to put "nothing" value is arguable in its
> own right.
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/
> mailman/listinfo.cgi/boost
>


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