Boost logo

Boost Users :

Subject: [Boost-users] [Boost.Preprocessor] Why BOOST_PP_SEQ_CAT with a sequence of comma separated pair is a missuse ?
From: Albert (albertembedded_at_[hidden])
Date: 2014-03-11 05:46:28


Hello,

I tried to use the BOOST_PP_SEQ_CAT with a sequence of parenthesized
comma-separated pair of token. It works fine with visual 2010 but fails
with gcc. I first think that there were a problem in the specific gcc
implementation part. That's why I opened the issue 9633 :
https://svn.boost.org/trac/boost/ticket/9633
But, it has recently been closed for invalidity, the corrector telling
that it is not a valid use.

I have not read the entire help of the PP library but as far as I
understand the sequence definition given in A.4.5.1.
(http://www.boostpro.com/mplbook/preprocessor.html) as "any string of
nonempty parenthesized /macro arguments/." and the definition of macro
arguments in A.2.3, I fail to see why the sequence could be incorrect.
Specially when I read the end of the paragraph :
"
It /is/ possible to pass either string of tokens above as part of a
single macro argument, provided it is parenthesized:

FOO(*(*std::pair<int,int>*)*) // one argument
FOO(*(*{ int x = 1, y = 2; return x+y; }*)*) // one argument

"

I fail to see where in the dedicated entry for BOOST_PP_SEQ_CAT
(http://www.boost.org/doc/libs/1_55_0/libs/preprocessor/doc/ref/seq_cat.html)
there is a rule I violated.

So my questions are :
=> why the code I proposed is invalid ?
=> Is the workaround proposed with BOOST_PP_SEQ_FOR_EACH is also a
missused and may fail according to evolutions of the library ?

Thanks in advance for your answers.

The code :

#include <boost\preprocessor\seq\cat.hpp>

#define SOME_SEQUENCE (('a',1)) (('b',2)) (('c',3)) (('d',4)) (('e',5))

struct dummy
{
     dummy& operator()(char,int) {return *this;}
};

int main()
{
     dummy() BOOST_PP_SEQ_CAT(SOME_SEQUENCE);
// Visual 2010 generates dummy() ('a',1)('b',2)('c',3)('d',4)('e',5);
// gcc fails with compiler errors due to the comma I suppose
  return 0;
}



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