views:

90

answers:

0

I have a boost pre-processor sequence defined as

 #define  MY_SEQ ((a) (b1) (b2))\
    ((b) (b3) (b4) (b1))

I want to generate two enums from this as, enum alist{a,b}; and enum blist{b1,b2,b3,b4}; The code below does not remove the duplicates from blist (LIST2 macro). Is it possible to remove the duplicates from the pre-processor list ?

 #define LIST1_HOLDER
 #define GEN_LIST1(r,data,elem) BOOST_PP_SEQ_PUSH_BACK(LIST1_HOLDER,BOOST_PP_SEQ_HEAD(elem))
 #define LIST1 BOOST_PP_SEQ_FOR_EACH(GEN_LIST1,,MY_SEQ)

 #define LIST2_HOLDER
 #define BUILD_LIST2(r,data,i,elem) BOOST_PP_SEQ_PUSH_BACK(LIST2_HOLDER,elem)
 #define GEN_LIST2(r,data,elem)  BOOST_PP_SEQ_FOR_EACH_I(BUILD_LIST2,BOOST_PP_SEQ_HEAD(elem),BOOST_PP_SEQ_TAIL(elem))
 #define LIST2 BOOST_PP_SEQ_FOR_EACH(GEN_LIST2,,MY_SEQ)
 enum alist
 {
    BOOST_PP_SEQ_ENUM(LIST1)
 };
 enum blist
 {
    BOOST_PP_SEQ_ENUM(LIST2)
 };

Thanks