
On 2012-09-02 23:34, Lorenzo Caminiti wrote:
On Sun, Sep 2, 2012 at 1:17 PM, Lorenzo Caminiti <lorcaminiti@gmail.com> wrote:
On Sun, Sep 2, 2012 at 12:30 PM, Roland Bock <rbock@eudoxos.de> wrote:
[...]
Obviously, if I could use the preprocessor to translate
Alpha = 5 -> (Alpha, 5)
I'd be done. But I have no idea how to do that. Any suggestions? There's no way you can strip the = symbol with the pp. You can only do:
Alpha = 5 -> (Alpha =, 5) Actually, I don't think you can't even do this because if you concatenate from the back Alpha = 5 ## _SPLIT_NUM then 5_SPLIT_NUM is not a valid macro identifier :( Otherwise, the idea would be to:
#define 5_SPLIT_NUM , 5 ... // #define for all ints [0, 255] #define SPLIT(int_assignment) BOOST_PP_CAT(int_assignment, _SPLIT_NUM)) SPLIT(Alpha = 5)
You could do something different (and more alphanumeric) all together... but I'm not sure if I'd advice it:
CREATE_CONVERTER_METHODS(Greek, 5 as Alpha, 3 as Beta, 7 as Gamma, 1 as Delta, 6 as Epsilon )
Now: 5 as Alpha -> (Alpha, 5).
That certainly looks a bit weird, but thanks for explaining in such detail to someone who is not really used to preprocessor programming :-) Regards, Roland