Subject: Re: [boost] optional<optional<T>>
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-09-02 23:34:13
> On Wed, Sep 2, 2009 at 8:43 PM, Andrei
> Alexandrescu<andrei_at_[hidden]> wrote:
>> 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.
> Personally I would find it interesting as it can hold extended data,
> but perhaps it would be nice to fold someway so it takes less data,
> perhaps one bit per sub-optional used up to the overall max of a char
> or int or something (would anyone really have 8 optionals embedded?)
I think, if folding should be supported then it should be done through
an external metafunction, something like:
typedef typename fold_optionals< T, 7 >::type single_optional;
I think, the default behavior of optional should stay as is.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk