Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-06-05 15:17:27


I must be doing something stupid. How can I process a sequence of
sequences? I expected to be able to use nested invocations of
SEQ_FOR_EACH, but I'm not getting the results I expect. Here's my code:

   #include <boost/preprocessor.hpp>

   #define INNER(R, DATA, ELEM)\
       **ELEM**,

   #define OUTER(R, DATA, ELEM)\
       << BOOST_PP_SEQ_FOR_EACH_R(R, INNER, ~, ELEM) >>,

   BOOST_PP_SEQ_FOR_EACH(OUTER, ~, ((1)(2)) ((3)(4)) )

I expected something like:
   << **1**, **2**, >>, << **3**, **4**, >>,

But instead I'm getting:
<< BOOST_PP_SEQ_FOR_EACH_M(3, (INNER, ~, (1)(2) (nil)))
BOOST_PP_SEQ_FOR_EACH_M(4, (INNER, ~, (2) (nil))) >>, <<
BOOST_PP_SEQ_FOR_EACH_M(4, (INNER, ~, (3)(4) (nil)))
BOOST_PP_SEQ_FOR_EACH_M(5, (INNER, ~, (4) (nil))) >>,

I've tried both msvc-8.0 and gcc-3.4. Can anybody see my mistake?

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk