|
Boost : |
Subject: Re: [boost] [optional] Safe optional
From: Vladimir Batov (Vladimir.Batov_at_[hidden])
Date: 2014-11-19 17:57:07
On 11/20/2014 09:12 AM, Vicente J. Botet Escriba wrote:
> Le 19/11/14 22:36, Vladimir Batov a écrit :
>>
>> ...
>> On the second thought I might probably agree that op<() might be
>> questionable... Can we address that differently then? Say,
>>
>> bool operator<(T const&, optional<T> const&) { BOOST_STATIC_ASSERT(); }
>>
>>
> I don't think this is a solution. User defining its own function
>
> void f(optional<T>, optional<T>);
>
> would need to add the following?
>
> void f(T, optional<T>) { BOOST_STATIC_ASSERT(); }
> void f(optional<T>, T) { BOOST_STATIC_ASSERT(); }
>
> What if there are 3 optional parameters? We can not say to the user
> that they need to program this way.
That's immensely different... and it should not be prohibited... T to
optional<T> is natural propagation/conversion... as 'int' to 'double'.
That should happen automatically and seamlessly... as 'int' to 'double'.
In the other direction -- optional<T> to T -- like double to int, needs
to be explicit... and it is.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk