Switch library overloads of call operator

Hi Another question about the design / docs for the switch library under review. From what I understand switch takes a runtime integral value, uses a PP generated switch statement, and calls out using some sort of MPL integral constant to specify the switch case to be served. This is pretty cool, as we seem to be travelling back from runtime into compile time world. 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. 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. Otherwise I'm going to have to use enable_if or something to separate out the cases, which seems unnecessarily awkward. The example provided is fortunate that it behaves uniformly for each incoming value, so only 1 overload of operator() is required. IMO this will not be the common case, an example with differing behaviour would be helpful. I think the documentation could do with a bit of clarification in this area. Cheers Dan ___________________________________________________________ Support the World Aids Awareness campaign this month with Yahoo! For Good http://uk.promotions.yahoo.com/forgood/

AMDG dan marsden <danmarsden <at> yahoo.co.uk> writes:
Another question about the design / docs for the switch library under review.
From what I understand switch takes a runtime integral value, uses a PP generated switch statement, and calls out using some sort of MPL integral constant to specify the switch case to be served. This is pretty cool, as we seem to be travelling back from runtime into compile time world.
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.
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? In Christ, Steven Watanabe
participants (3)
-
dan marsden
-
Steven Watanabe
-
Tobias Schwinger