Boost.prepossor上的理由使用宏而不是简单的定义?
-
14-11-2019 - |
题
例如,BOOST_PP_ITERATE
和BOOST_PP_ITERATION
,如gman的answere 这里
解决方案
Generally, function like macro can be used to prevent unintentional macro
expansion.
For example, assuming that we have the following macro call:
BOOST_PP_CAT( BOOST_PP_ITERATION, _DEPTH )
and we expect this will be expanded into BOOST_PP_ITERATION_DEPTH
.
However, if BOOST_PP_ITERATION
is an object like(non-functional) macro,
it will be expanded to its own definition before the token
BOOST_PP_ITERATION_DEPTH
is generated by concatenation.
其他提示
Presumably because they perform operations: consequently, their usage should make it clear that you are actually invoking something and not just using some constant.
不隶属于 StackOverflow