
Joel de Guzman wrote:
Stjepan Rajko wrote:
"A" seems ideal for this use case. I have trouble seeing how to use "B" for it (easily) without making it so that the index is passed to the function object and allowing something like case<range>(...). But I might not be seeing all the possibilities. How can I implement this using "B"?
Ok, you are right. There is indeed no way to "bind" the case (a compile time constant (e.g. mpl::int_)). It is indeed crucial to have the case passed as the argument. Once we have it, then (I'm inventing some more syntax):
switch_<RT>(n)(all_cases(f));
Heh, that won't work. You really need to supply the cases: switch_<RT>(n)(case_range<From, To>(f));
Come to think of it, this is the only solution needed to map an A-style all-in-one-function to B! No need for Fusion, no need for extra infrastructure. All we need to do is pass the case as an argument to f.
The key point (and one that I am trying to capture) is to define the Concept of a Case. That is crucial. Once that's done, everything flows naturally.
I'll try to come up with a complete interface proposal that will encompass all use cases. It will be lightweight (no need for extra infrastructure) and efficient. I believe it can be done. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net