|
Boost Users : |
From: John C. Femiani (john.femiani_at_[hidden])
Date: 2008-07-22 01:14:02
Kevin Jenkins wrote:
> Is there any way to automate this, to support from 0 to n parameters?
>
> template <class P1, class P2, class P3, class P4, class P5>
> 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net