Boost logo

Boost Users :

Subject: Re: [Boost-users] Preprocessor to generate enum
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2009-02-02 08:56:32


Hansi a écrit :
> Hi,
>
> what is the best way to generate the following enum with the
> preprocessor library (boost 1.34.1)?
>
> enum
> {
> R1=0,
> R2=1,
> ...
> };
>

Dismiss latest olution, I misread the vlaue :

#define ENUM_VAL(z,n,text) BOOST_PP_CAT(text,n) = BOOST_PP_DEC(n)
#define N 4

enum
{
   BOOST_PP_ENUM_SHIFTED(N,ENUM_VAL,R)
};

should generate :

enum
{
   R1=0, R2=1,R3=2
};


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