Preprocessor to generate enum

Hi, what is the best way to generate the following enum with the preprocessor library (boost 1.34.1)? enum { R1=0, R2=1, ... }; Best regards Hansjörg

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, ... };
Best regards Hansjörg
Something like #define ENUM_VAL(z,n,text) BOOST_PP_CAT(text,n) = BOOST_PP_DEC(n) enum { BOOST_PP_ENUM(4,ENUM_VAL,R) };

Joel Falcou schrieb:
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, ... };
Best regards Hansjörg
Something like
#define ENUM_VAL(z,n,text) BOOST_PP_CAT(text,n) = BOOST_PP_DEC(n) enum { BOOST_PP_ENUM(4,ENUM_VAL,R) };
Thanks!

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 };
participants (2)
-
Hansi
-
Joel Falcou