|
Boost Users : |
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-02-27 10:41:36
AMDG
Hicham Mouline wrote:
> hi,
> in an ealier post, i was helped to write explicit template instantiations as:
>
> #define FINH1 (EC)(EP)(AC)(AP)
> #define FINH2 (C)(D)(E)(F)(G)
> #define FINH3 (2)(3)
> #define M(r, product) template class Tree<BOOST_PP_SEQ_ENUM(product)>;
> BOOST_PP_SEQ_FOR_EACH_PRODUCT(M, (FINH1)(FINH2)(FINH3))
>
> That nicely generated:
> template class Tree<EC,C,2>;
> template class Tree<EC,C,3>;
> template class Tree<EC,D,2>;
> template class Tree<EC,D,3>;
> ...
>
> what i need now is coupling FINH2 and FINH3 (i don't want their crossproduct) as in:
> #define FINH1 (EC)(EP)(AC)(AP)
> #define FINH2 (C,2)(D,2)(E,3)(F,3)(G,3)
>
> #define M(r, product) template class Tree<BOOST_PP_SEQ_ENUM(product)>;
> BOOST_PP_SEQ_FOR_EACH_PRODUCT(M, (FINH1)(FINH2))
>
> But that does't work because the commas in FINH2 are taken as macro arguments which fails...
>
#include <boost/preprocessor/seq/for_each_product.hpp>
#include <boost/preprocessor/seq/enum.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/seq/elem.hpp>
#define FINH1 (EC)(EP)(AC)(AP)
#define FINH2 ((C)(2))((D)(2))((E)(3))((F)(3))((G)(3))
#define M(r, product) template class Tree<BOOST_PP_SEQ_ELEM(0, product),
BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_ELEM(1, product))>;
BOOST_PP_SEQ_FOR_EACH_PRODUCT(M, (FINH1)(FINH2))
In Christ,
Steven Watanabe
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net