BOOST_PP_CAT宏
来源:互联网 发布:免费开淘宝店流程视频 编辑:程序博客网 时间:2024/06/18 05:58
BOOST_PP_CAT宏主要用来连接两个标识符。此宏被其它地方用到。
定义此宏的头文件boost\preprocessor\cat.hpp
# define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b)
# define BOOST_PP_CAT_I(a, b) BOOST_PP_CAT_II(~, a ## b)
# define BOOST_PP_CAT_II(p, res) res
为什么BOOST_PP_CAT宏要定义这么多辅助宏(BOOST_PP_CAT_I和BOOST_PP_CAT_II)呢?为什么不直接如下定义:
#define BOOST_PP_CAT_SIMPLE(a, b) a##b
原因是这两者之间是有细微的差别的。
请看下面的例子。
int AB = 512;
int A1 = 1024;
#define B 1
#define C1 BOOST_PP_CAT(A, B)
#define C2 BOOST_PP_CAT_SIMPLE(A, B)
这样定义以后,C1是A1,而C2是AB。也就是说:如果b不是宏,BOOST_PP_CAT和BOOST_PP_CAT_SIMPLE没有区别;如果b是宏,BOOST_PP_CAT_SIMPLE依然是直接连接,而BOOST_PP_CAT宏是先将b宏展开,然后连接。
0 0
- BOOST_PP_CAT宏
- BOOST_PP_CAT / BOOST_PP_SEQ_CAT / BOOST_PP_SEQ_SIZE / BOOST_PP_SEQ_HEAD / BOOST_PP_LESS_EQUAL 等 模拟编译器的推导过程
- 宏
- 宏
- ##宏
- 宏
- 宏
- 宏
- 宏
- 宏
- 宏
- 宏
- 宏
- 宏
- 宏
- 宏
- 宏
- 宏
- 椭圆曲线、双线性对学习资料
- 任意输入三个数是否能构成三角形
- codechef April challenge (1)(学习去优化时间效率???)
- 一个题目以及自己写的程序,求指导一下
- @+id/android:list"和"@android:id/list"的写法
- BOOST_PP_CAT宏
- 常量指针与指针常量
- redis配置文件redis.conf参数说明
- [LeetCode] 3Sum
- Android surfaceview使用——重载onTouchEvent
- 大小之差
- asp.net如何把文件上传到另外一台服务器
- leetcode: Binary Tree Inorder Traversal
- MySQL主从安装