1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/arithmetic/inc.hpp>
#include <boost/preprocessor/cat.hpp>
#include <iostream>
#define PC(id,msg) struct P##id { static void Action() { std::cout << #msg << "\n"; } };
PC(1,POne) PC(2,PTwo) PC(3,PThree) PC(4,PFour) PC(5,PFive) PC(6,PSix) PC(7,PSeven)
template<class PL, class PR> struct Test { void Run() { PL::Action(); PR::Action(); } };
#define INNER_LOOP(z,rightPn,leftPn) \
Test< P##leftPn , BOOST_PP_CAT(P,BOOST_PP_INC(rightPn)) > ().Run(); std::cout << "\n";
#define OUTER_LOOP(z,leftPn,unused) BOOST_PP_REPEAT(7,INNER_LOOP,BOOST_PP_INC(leftPn)) \
std::cout << "(hit enter to continue...)\n\n"; std::cin.get();
#define DO_IT_AND_WHEN_YOU_RE_DONE std::cout << "\n"; BOOST_PP_REPEAT(7,OUTER_LOOP,~)
int main() { DO_IT_AND_WHEN_YOU_RE_DONE return 0; }
|