|
Boost Users : |
Subject: Re: [Boost-users] [preprocessor] How to transform sequence into sequence of tuples.
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2013-04-12 07:21:59
On Thu, 11 Apr 2013 23:31:07 -0700, Nathan Ridge <zeratul976_at_[hidden]>
wrote:
>> Ah, thanks. I was going down the BOOST_PP_SEQ_FOR_EACH path. My
>> algorithm
>> was going to be
>>
>> #define SEQ (a)(b)(c)(d)
>> #define WRAP(r, data, elem) \
>> LPAREN_IF(MOD(elem-index,2)) elem COMMA_IF(MOD(elem-index,2))
>> RPAREN_IF(NOT(MOD(elem-index,2)))
>> SEQ_FOR_EACH(WRAP, ~, SEQ)
>>
>> But I couldn't figure out how to get the element index.
>
> If you use SEQ_FOR_EACH_I, the element index will be passed in as an
> extra argument to WRAP.
Ah, thanks.
(It would be very helpful if the distinction between SEQ_FOR_EACH_I and
SEQ_FOR_EACH was emphasized in the former, preferably in the short
description at the top of the reference page for SEQ_FOR_EACH_I.)
>> BTW, what is the
>> "next available BOOST_PP_FOR repetition" in the ternary macro for
>> SEQ_FOR_EACH?
>
> This is explained in Topics -> Reentrancy in the Boost.PP docs.
Thanks again.
(This again demonstrates the need for internal references/links in the
documentation. One shouldn't have to read the *whole* documentation to
effectively use parts of the library. This is very doable when parts of
the library properly link to other relevant and dependent parts.)
Thanks for the pointers.
Mostafa
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