Boost Preprocessor is so cool

#include "boost/preprocessor/seq/size.hpp"
#include "boost/preprocessor/seq/elem.hpp"
#include "boost/preprocessor/seq/push_back.hpp"
#include "boost/preprocessor/stringize.hpp"
#include "boost/preprocessor/iteration/local.hpp"

#include "boost/preprocessor/arithmetic/add.hpp"
#include "boost/preprocessor/arithmetic/div.hpp"
#include "boost/preprocessor/arithmetic/mul.hpp"
#include "boost/preprocessor/arithmetic/dec.hpp"
#include "boost/preprocessor/arithmetic/mod.hpp"

#include "boost/preprocessor/debug/assert.hpp"
#include "boost/preprocessor/comparison/equal.hpp"

#define SEQ_DIM 4
#define SEQ0 (a)(b)(c)(d) \
             (a1)(b1)(c1)(d1)

BOOST_PP_ASSERT_MSG(BOOST_PP_EQUAL(BOOST_PP_MOD(BOOST_PP_SEQ_SIZE(SEQ0), SEQ_DIM), 0), \
					"#error SEQ has to be aligned with 4")

#define BOOST_PP_LOCAL_MACRO(n) printf("%s %s %s %s\n",			 \
		BOOST_PP_STRINGIZE(BOOST_PP_SEQ_ELEM(BOOST_PP_ADD(BOOST_PP_MUL(n, SEQ_DIM), 0), SEQ0)), \
		BOOST_PP_STRINGIZE(BOOST_PP_SEQ_ELEM(BOOST_PP_ADD(BOOST_PP_MUL(n, SEQ_DIM), 1), SEQ0)), \
		BOOST_PP_STRINGIZE(BOOST_PP_SEQ_ELEM(BOOST_PP_ADD(BOOST_PP_MUL(n, SEQ_DIM), 2), SEQ0)), \
		BOOST_PP_STRINGIZE(BOOST_PP_SEQ_ELEM(BOOST_PP_ADD(BOOST_PP_MUL(n, SEQ_DIM), 3), SEQ0))	);

#define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_DEC(BOOST_PP_DIV(BOOST_PP_SEQ_SIZE(SEQ0), SEQ_DIM)))
#include BOOST_PP_LOCAL_ITERATE()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值