Subject: Re: [boost] What about "Maybe" ?
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-12-20 21:55:00
On Sun, Dec 20, 2009 at 7:30 PM, Larry Evans <cppljevans_at_[hidden]> wrote:
> On 12/20/09 20:11, OvermindDL1 wrote:
>> On Sun, Dec 20, 2009 at 6:48 PM, Arnaud Masserann <arnaud1602_at_[hidden]>
>>> Is there any interest for a "Maybe" utility class, like the one in
>>> Haskell ?
>>> For those who don't know about Maybe, here is the Haskell ref :
>>> And a code snippet showing its use :
>> It looks like Boost.Optional from how it is used in your pastebin
>> snippet. Â How is it different from Boost.Optional?
> Boost Optional looks like variant with a single component and
> *without* the never empty guarantee:
> Instead of Optional, why not adapt variant to do both what variant does
> and what optional does? Â All that would be required is simply allowing
> an empty variant which could always be detected with a test for
> which() == -1.
Actually optional is pretty near to being exactly:
optional<T> == variant<nil_t,T>
And an easier accessor function of course.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk