+1  A: 

To use BOOST_PP_ENUM in the way that you've shown, you would need a macro that takes a 'number' and yields an expression that is the address of an appropriate member of the appropriate class. I don't see a good way to do this without an explicit list unless the desired functions all have manufactured names (e.g. memfun1, memfun2, etc.). Except in the case, it's going to be easier to list the function address expressions explicitly that to used BOOST_PP_ENUM.

You are using identifiers in this array that are the same as the template parameters in Some_class.

R (U::* const pmfi[])(T&) = { /* ... */ }

Is this really supposed to be the templated member of Some_class?

template< class T, class U, class R >
R (U::* const Some_class<T, U, R>::pmfi[])(T&) = { /* ... */ }

If so, is the same instantiation going to work with all combinations of types that you are going to us the template Some_class with? If so, you have a very constrained set of classes, perhaps you can do away with the template. If not, you are going to have to specialize Some_class for every combination of template parameters in which case the template is not gaining you very much.

Edit, post edit: If I've understood you correctly then you can't do what you've suggested because the array of pointers must be of exactly the right signature.

Reducing it to a simple function pointer example, you can't do this:

void f(Derived&);

void (*p)(Base&) = &f;

otherwise, it would subvert type safety:

OtherDerived od; // derived from Base, but no from Derived

 // I've managed to pass something that isn't a Derived reference to f
 // without an explicit (and dangerous) cast
(*p)(od);

In your array of function pointers, the initializers must all be to functions of the right signature.

Charles Bailey
Hi, Charles1. Indeed, I use a "seq" from boost.preprocessor to expand `BOOST_PP_ENUM` and to generate a typelist (used in the process)2. Those are not real code. The identifiers in the code should be meant as typedefs of the template argsIf R, T, U are typedefs of template args of Some_class (forget the rest), array definition would beSome_class::R (Some_class::U::* const Some_class::pmfi[])(Some_class::T
Josuel
Josuel
"Those are not real code." Then can you _carefully_ post some real code and describe the problem that you are trying to solve. Your solution looks overly complex, but without knowing what the problem is, it's difficult to say. In particular can you post a sample class that you want to use for the template parameter `U` (or is it `U1` now?) and also where `Types` and the metafunction `Length` are defined? Post edit, you now seem to have an error in the declaration of `Some_class::pmfi`.
Charles Bailey
Sorry. I redefined the question (I hope with unneeded information stripped out).
Josuel
I was afraid of the answer being the functions signatures. As you can assign an object of a derived class to a base class pointer, I thought a base class pointer could accept the address of a derived member class function. Shame on me! Thanks for spending your time with such a foolish question.
Josuel