Boost logo

Boost :

Subject: Re: [boost] boost::optional<void>
From: Roman Kecher (roman.kecher_at_[hidden])
Date: 2010-03-01 05:05:22


I feel that boost::optional has no sensible implementation for
optional<void>, since there's absolutely nothing optional when returning
void; When the function returns (if no exception is thrown, of course),
the 'void value' is returned. Therefore, optional<void> can't be a boolean
as it only has one possible 'value' which always exists.

Having said that, I can see that such implementation would ease things on
your end. However, I can't see a way to incorporate it into the existing
boost::optional.

I'll be happy to hear (read) more opinions, though.

On Mon, Mar 1, 2010 at 9:00 AM, Daniel Larimer <dlarimer_at_[hidden]> wrote:

> I am writing some generic code and would like to handle "all values" the
> same way; however, I keep running into the problem of return void return
> types that need "special treatment". There is nothing I can do about it
> most of the time except template specialization.
>
> That said, it would be helpful if boost::optional<void> could have some
> sensible default implementation where it acts more or less like a boolean.
> As it is, I will probably provide my own specialization of boost::optional
> to simplify my templates.
>
> Any thoughts on this?
>
> Dan
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

-- 
Roman Kecher ... .. . http://cplusplus.co.il

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