|
Boost : |
From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-06-19 20:52:45
Paul Mensonides wrote:
> // file.hpp
> #if !defined(BOOST_PP_IS_ITERATING)
>
> #ifndef FILE_HPP // normal file begins here
> #define FILE_HPP
>
> #include <boost/preprocessor/comma_if.hpp>
> #include <boost/preprocessor/iterate.hpp>
> #include <boost/preprocessor/repeat.hpp>
>
> template<int> struct test; // no def
> template<> struct test<0>; // no def
>
> #define BOOST_PP_BOUND 1
> #include BOOST_PP_SET_LBOUND()
>
> #define BOOST_PP_BOUND 100
> #include BOOST_PP_SET_UBOUND()
>
> #define BOOST_PP_FILENAME_1 "file.hpp"
> #include BOOST_PP_ITERATE()
>
> #endif // end of normal file
>
> #else // this part get iterated over
> #line BOOST_PP_LINE(__LINE__, file.hpp) // for debugging
> #define C BOOST_PP_FILE_ARG() // temporary
>
> #define ABC(n, nil) BOOST_PP_COMMA_IF(n) class T ## n
>
> template<> struct test<C> {
> template<BOOST_PP_REPEAT(C, ABC, nil)>
> struct args { /* whatever */ };
> };
>
> #undef ABC
> #undef C
> #endif
Cool! Is second-level recursion possible?
Aleksey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk