From: dan marsden (danmarsden_at_[hidden])
Date: 2008-01-05 16:21:23
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.
Support the World Aids Awareness campaign this month with Yahoo! For Good http://uk.promotions.yahoo.com/forgood/
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk