Boost logo

Boost :

From: Rene Rivera (grafik666_at_[hidden])
Date: 2002-04-11 20:07:15


On 2002-04-11 at 07:25 PM, david.abrahams_at_[hidden] (David Abrahams) wrote:

>How can I make a macro which, given an integer N, generates a sequence
>of
>N concatenated Xs?
>
>IOW,
>
> Xs(0) ->
> Xs(5) -> XXXXX
>
>....and so forth?
>
>Fortunately, in my case I need a string literal so I don't actually need
>to catenate them (I can rely on "X" "X" "X" to generate "XXX") but the
>problem still looks unreasonably hard-to-solve with BPPL.
>
>TIA,
>Dave

I think this will work...

#define Xs_(x) x
#define Xs0(x)
#define Xs1(x) Xs_(x)
#define Xs2(x) Xs_(x)Xs_(x)
#define Xs3(x) Xs_(x)Xs_(x)Xs_(x)
#define Xs4(x) Xs_(x)Xs_(x)Xs_(x)Xs_(x)
#define Xs(count) Xs##count(X)

But then again, only good for up to a set number.

-- grafik - Don't Assume Anything
-- rrivera_at_[hidden] - grafik_at_[hidden]
-- 102708583_at_icq - Grafik666_at_AIM - Grafik_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk