From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-03-08 09:04:44
----- Original Message -----
From: "vesa_karvonen" <vesa_karvonen_at_[hidden]>
Sent: Friday, March 08, 2002 8:24 AM
Subject: [boost] Re: boost::bind and the preprocessor
> --- In boost_at_y..., "Peter Dimov" <pdimov_at_m...> wrote:
> > I haven't found the 'perfect' solution to this problem yet. The
> > preprocessor library has the advantage that the preprocessor is
> > always present; but it adds a significant amount of obfuscation.
> Macro definitions can be a bit difficult to read when they are mixed
> with ordinary C++ code. Macro uses, on the other hand, are not very
> difficult to read. Most of the macros offered by the preprocessor
> library are rather fundamental and should not, IMHO, take a lot of
> time to understand. Take BOOST_PP_REPEAT() for example.
> #define BOOST_PP_REPEAT(N,M,P)
> Repeats the macro M(I,P) for I = [0,N[.
> In other words, expands to the sequence:
> M(0,P) M(1,P) ... M(BOOST_PP_DEC(N),P)
> I don't know how to make this any simpler.
M(0,P) M(1,P) ... M(N-1,P)
Note: If N is 10, this will be the token 9, not 10-1.
#define FOO(n, x) + BOOST_PP_CAT(x, n)
BOOST_PP_REPEAT(3, FOO, bar) => + bar1 + bar2 + bar3
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk