Boost logo

Boost Users :

Subject: Re: [Boost-users] [preprocessor]
From: Christian Henning (chhenning_at_[hidden])
Date: 2009-12-13 14:27:11


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?

Thanks,
Christian


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