|
Boost : |
From: Douglas Gregor (gregod_at_[hidden])
Date: 2004-02-17 18:45:19
On Tuesday 17 February 2004 05:01 pm, Jody Hagins wrote:
> asserts (if the default combiner is used). I guess that makes sense,
> because there can be no "combined" return value if there are no slots.
> However, an assertion seems a bit harsh. I am really not sure what
> should happen, but maybe an exception is a better alternative,
Well, we could throw bad_function_call, perhaps, or pick/create some other
exception (I'm at a loss for exception names for this).
> or maybe
> an alternative interface can define a default value to be returned if
> there are no slots connected), or maybe something else...
Well, you can always write a different combiner that does this.
> Anyway, I guess I was wanting to know why this is the case, and what is
> the usual method of handling this circumstance. I assume something
> like:
>
> if (!sig.empty())
> {
> result = sig();
> }
>
> but that just does not look pretty...
No, it isn't pretty; perhaps the exception is the right way to go, depending
on your application.
Doug
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk