使用BOOST_PP_FOR_EACH获取复合元素列表

时间:2018-03-23 14:37:53

标签: c++ boost-preprocessor

是否可以使用Boost preprocessor library转换此代码:

#define PROCEDURES\
    (procedureNameA, procedureIdA, procedureTypeA, procedureOutcomeA)\
    (procedureNameB, procedureIdB, procedureTypeB, procedureOutcomeB)\
    (procedureNameC, procedureIdC, procedureTypeC, procedureOutcomeC)\
    (procedureNameD, procedureIdD, procedureTypeD, procedureOutcomeD)

到这段代码片段:

{ procedureIdA * 10 + procedureTypeA, "procedureNameA"},
{ procedureIdB * 10 + procedureTypeB, "procedureNameB"},
{ procedureIdC * 10 + procedureTypeC, "procedureNameC"},
{ procedureIdD * 10 + procedureTypeD, "procedureNameD"}

如果是这样,怎么样?如果它更容易,我也会接受非Boost替代品。我也愿意改变定义列表的方式以使转换成为可能。

0 个答案:

没有答案