Boost logo

Boost :

From: Stjepan Rajko (stipe_at_[hidden])
Date: 2008-01-10 17:55:07


On Jan 9, 2008 6:55 AM, Tobias Schwinger <tschwinger_at_[hidden]> wrote:
> Stjepan Rajko wrote:
> > * What is your evaluation of the design?
>
> A default case function object returning 'void' should be assumed (and
> 'assert'ed) not to return in a context where a (non-void) result is
> expected (implementation hint: the built-in comma operator allows void
> arguments and an overloaded comma operator doesn't).
>

I can see why having a non-returning default case function object
would be a common use case (e.g., throw on non-specified case), but
technically, why should the default case be treated differently than
the regular cases in this respect? E.g., what if I wanted to throw on
case 3 but return something by default?

It seems that the cleanest solutions here would be to either allow
void-returning function objects (when a return type is expected) both
for regular and default cases (and assert that the call does not
return), or disallow the void-returning function objects all together
(when a return type is expected).

Just my 2 cents...

Regards,

Stjepan


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