Boost logo

Boost Users :

Subject: Re: [Boost-users] [preprocessor] variable repetition
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2010-05-31 11:19:40


2010/5/31 Manfred Doudar <manfred.doudar_at_[hidden]>

> Hello,
>
> I find I am still far from a solution to this, and hope someone might
> kindly chime in. At the _bottom_ of this email is what I've got so far,
> though falls short of a solution... help is still sorely needed.

#include <boost/preprocessor.hpp>

#define VAR(z, n, k) \
    bar<BOOST_PP_ENUM_PARAMS(k, T)>(a[n]);

#define FUN(n) \
   void foo(BOOST_PP_ENUM_PARAMS(n, T)) \
   { \
       BOOST_PP_REPEAT(n, VAR, n) \
   }

#define BOOST_PP_LOCAL_MACRO(n) FUN(n)
#define BOOST_PP_LOCAL_LIMITS (1, 3)
#include BOOST_PP_LOCAL_ITERATE()

By the way, you don't have to undef BOOST_PP_LOCAL_MACRO
and BOOST_PP_LOCAL_LIMITS. They are undef-ed in BOOST_PP_LOCAL_ITERATE.

Roman Perepelitsa.



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