Re: [boost] Switch library overloads of call operator

Steven Watanabe wrote:
dan marsden <danmarsden <at> yahoo.co.uk> writes:
The documentation is not specific about which specific type (e.g. mpl::int_<1> for case 1 matching in the underlying switch statement) is going to be used. The type that is passed to f is whatever is in the list of cases.
Ok cool.
It looks to me like it would be convenient to overload operator() for each case I want to service, but this will be awkward to do without knowing the exact type that will be incoming.
<snip>
If multiple cases are not grouped together, I don't see how it's an advantage to use my library vs. using a plain old hand-written switch. Would you mind elaborating?
I think you're probably right, my original suggestion that multiple overloads of operator() would be likely is probably wrong. I can only suggest handling special cases such as divide by zero for example, but I think my original suggestion may be a red herring. Cheers Dan ___________________________________________________________ Support the World Aids Awareness campaign this month with Yahoo! For Good http://uk.promotions.yahoo.com/forgood/

dan marsden wrote:
Steven Watanabe wrote:
If multiple cases are not grouped together, I don't see how it's an advantage to use my library vs. using a plain old hand-written switch. Would you mind elaborating?
I think you're probably right, my original suggestion that multiple overloads of operator() would be likely is probably wrong. I can only suggest handling special cases such as divide by zero for example, but I think my original suggestion may be a red herring.
I can imagine that grouping overloads using 'enable_if' and a condition could be useful, occasionally. Regards, Tobias
participants (2)
-
dan marsden
-
Tobias Schwinger