Boost logo

Boost :

From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2005-10-24 11:57:17


Simon Buchan wrote:
> Fernando Cacciola wrote:
>> Reece Dunn wrote:
>>
>>> Fernando Cacciola wrote:
>>>
>>>> Sam Partington wrote:
>>>>
>>>>> [...]
>>>
>>> Why not use partial specialization so that optional< T > has the
>>> semantic sugar, but optional< T & > does not? Or is this already the
>>> case?
>>>
>>
>> I'm not too fond of template classes that support different
>> interfaces according to the properties of the template parameters.
>> That just doesn't play along with generic programming where the type
>> you optionalize can or cannot be a reference.
>> Think of vector<bool> for instance.
>> I rather keep looking for a consistent solution.
>>
> The difference being that vector<bool> has semantic (but not
> syntactic) differences, while optional<T&> would have syntactic (but
> not semantic) differences.

Right.. though I'm still reluctant to give references a special syntax.

> And
>
> template <class T>
> optional<T> foo(optional<T> ot) {
> ...
> ot = optional<T>(someTexpr);
> ...
> }
>
> would always work.
>
That's why I suggest discarding direct assigment. Is only syntatic sugar.

> Personally, though, I think dropping optional<T&> would be perfectly
> acceptable.

Somewhat acceptable, yes, but I'm still trying to save it.

-- 
Fernando Cacciola
SciSoft
http://fcacciola.50webs.com/ 

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