Boost logo

Boost :

Subject: Re: [boost] optional<optional<T>>
From: Joel de Guzman (joel_at_[hidden])
Date: 2009-09-03 00:09:08


Joel de Guzman wrote:
> Andrey Semashev wrote:
>> Joel de Guzman wrote:
>>> Andrei Alexandrescu wrote:
>>>> Hello,
>>>>
>>>>
>>>> I'm defining an "optional" type for D's standard library modeled
>>>> similarly to Boost.optional. An interesting question came up -
>>>> should optional<optional<T>> fold itself into optional<T>, or is
>>>> "double optional" an interesting concept of its own?
>>>>
>>>> I thought I'd ask here because by now there's a significant body of
>>>> experience with optional<T>. I perused the online documentation and
>>>> the forum and couldn't find information about that specific detail.
>>>
>>> We use boost.optional extensively in Boost.Spirit. IIRC, we collapse
>>> such things. Usually they occur in generic code. I see no real need
>>> for optional<optional<T>>. If there's a use for it, I too would like
>>> to hear it.
>>
>> I use double optionals. Indeed, this appears in a generic code, but
>> it's intended.
>>
>> The point is that I use the outer optional to in-place construct
>> objects, and it sometimes happens that the objects themselves are
>> optionals. Making them not optional would not be correct from the
>> application logic point of view.
>
> Use case, please?

Ah, I see. Disregard that. I typed too quickly. That is a valid
use-case indeed.

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

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