22 Jul
2008
22 Jul
'08
5:14 a.m.
Kevin Jenkins wrote:
Is there any way to automate this, to support from 0 to n parameters?
template
bool DoIt(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { DoThat<P1>(p1); DoThat<P2>(p2); DoThat<P3>(p3); DoThat<P4>(p4); DoThat<P5>(p5); }
I think you can do it using Boost.Fusion or Boost.Preprocessor. For boost.fusion, I think you can you define the function to take a ::boost::fusion::vector, and use for_each to call a polymorphic function that calls DoThat. Then you make an unfused function from that. For boost.Preprocessor, you can generate a signature using macros like BOOST_PP_ENUM_PARAMS / ENUM_BINARY_PARAMS / REPEAT . --John