boost学习之BOOST_PP_REPEAT

来源:互联网 发布:慧莫森软件科技 编辑:程序博客网 时间:2024/06/03 14:04

BOOST_PP_REPEAT 是用来快速横向重复构造的宏。

用法

BOOST_PP_REPEAT(count, macro, data)

变量

变量 说明 count 指明了重复的次数 macro 被重复调用的宏的名称 data 原封不动传递给macro

附注

展开之后:

macro(z, 0, data) macro(z, 1, data) ... macro(z, count - 1, data)

使用方法

#include <boost/preprocessor/repetition/repeat.hpp>#define DECL(z, n, text) text##n=n;BOOST_PP_REPEAT(5, DECL, int x)
#include <boost/preprocessor/repetition/repeat.hpp>#define output_type(z, n, unused), typename Output##1BOOST_PP_REPEAT(5, output_type, ~)#undef output_type

头文件

#include <boost/preprocessor/repetition/repeat.hpp>
0 0
原创粉丝点击