
Hello everybody, I'm trying to use the boost preprocessor library to allow the user to define "rich" enums, for instance enums that cannot be converted to int, whose values can be displayed in human readable form on a stream... I think I have to use macro to ease the writing of such enums, and I decided it was a good occasion to learn boost::preprocessor. My first impression : Wow ! You guys really use magic when programming ! Now, I have to decide what will be the interfaces for such rich enums. My (unreachable) goal would be something like that : RichEnum Type{Val1, Val2, Val3}; A little bit more reasonnable (but still unacheivable, I believe) goal would be : RICH_ENUM(Type, Val1, Val2, Val3); I think I can come up with several possible writing : 1/ RICH_ENUM(Type, (Val1)(Val2)(Val3)); 2/ RICH_ENUM(Type, 3, (Val1,Val2,Val3)); 3/ #define NAME Type #define VALUES (Val1)(Val2)(Val3) #include "RichEnum.h" #undef NAME #undef VALUES 4/ same as 3/, but with tuple syntax for VALUES With 1/ and 2/, all the class declaration is on the same line, which could decrease debugability. With 3/ and 4/, I can write it one several lines. And now, the questions : Which writing do you think would be best ? Why ? Are there other possibilities I overlooked ? Is is possible to have a syntax like 1/ and 2/ with good debugability ? Regards, -- Loïc