Boost logo

Boost Users :

Subject: Re: [Boost-users] [preprocessor]
From: Christian Henning (chhenning_at_[hidden])
Date: 2009-12-14 10:31:32


Wow, thanks Steven. This is exactly what I'm looking for. Although, I
find the name BOOST_PP_SEQ_ENUM a bit odd.

Everything works now. And yes, there are way too many template
instantiations. ;-)

Christian

On Sun, Dec 13, 2009 at 6:05 PM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> AMDG
>
> Christian Henning wrote:
>>
>> Hi there, thanks Steven for your good advise. I have been making some
>> progress but I'm stuck on one part. Here is some code that exhibits my
>> problem.
>>
>> #include <boost/preprocessor.hpp>
>>
>> template< int i, int j > void test() {}
>>
>> int main()
>> {
>>    #define S1 (1)(2)(3)
>>    #define S2 (1)(2)(3)
>>    #define FOR_EACH( r, data, elem ) BOOST_PP_CAT( elem \
>>                                                  , BOOST_PP_COMMA() )
>>
>>    #define FOR_EACH_PRODUCT(r, product) test<  BOOST_PP_SEQ_FOR_EACH(
>> FOR_EACH \
>>                                                                     ,
>> BOOST_PP_EMPTY() \
>>                                                                     ,
>> product \
>>                                                                     ) >();
>>
>>    BOOST_PP_SEQ_FOR_EACH_PRODUCT( FOR_EACH_PRODUCT \
>>                                 , (S1)(S2) \
>>                                 )
>>
>>    return 0;
>> }
>>
>> Here is what the preprocessor produces:
>>
>> test< 1, 1,   >();
>> test< 1, 2,   >();
>> test< 1, 3,   >();
>> test< 2, 1,   >();
>> [snip]
>>
>>
>>
>> My problem is that I cannot figure out how to get rid of the last
>> comma? Any ideas?
>>
>
> BOOST_PP_SEQ_ENUM?
>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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