C++ preprocessor conditional parameter

前端 未结 4 792
抹茶落季
抹茶落季 2021-01-18 08:12

Please note C++03! any C++11 solutions are not good for me, but do post them just for knowledge sake.

I know the preprocessor can do things like:

#de         


        
4条回答
  •  野的像风
    2021-01-18 08:57

    If you can use Boost, you could do this with Boost.Preprocessor:

    #define BAR(X) BOOST_PP_EXPR_IF(BOOST_PP_EQUAL(X, 4), cout << "hi" << endl;)
    

提交回复
热议问题