[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-users
Subject:    Re: [Boost-users] BOOT_PP_REPEAT simple nesting problem
From:       "Hickman, Steve (AdvTech)" <Steve.Hickman () honeywell ! com>
Date:       2014-09-22 16:02:34
Message-ID: EA5676973A55CA4BA5D3F921E9FB1C17277EC08D () de08ex3003 ! global ! ds ! honeywell ! com
[Download RAW message or body]

You should try replacing the ## with BOOST_PP_CAT. The Preprocessor doc indicates \
that using ## directly can cause the preprocessor to terminate expansion.

---
Steve H.

-----Original Message-----
From: Colin Fowler [mailto:fowler@colinfowler.ie] 
Sent: Saturday, September 20, 2014 6:36 AM
To: Boost-users@lists.boost.org
Subject: [Boost-users] BOOT_PP_REPEAT simple nesting problem

Hi all, I'm trying to use BOOST_PP to generate some code.

I can generate the sequence int x_0 to int x_4 using the code below.

#include <boost/preprocessor/repetition/repeat.hpp>
#define DECL1(z, n, text) text ## _ ## n = n; #define decl1(text, count) \
BOOST_PP_REPEAT(count, DECL1, text) decl1 (int x, 5)


What I'd like to do is write a decl2 that can be used something like
this:

decl2 (int x, 5, 2)

to generate int x_0_0 to int x_4_1

I've tried nesting BOOST_PP_REPEAT but so far I've been unable to produce the desired \
behaviour unless I hardcode one of the iteration counts.

I'd like to also eventually write a decl3(int x, 5, 3, 4) when I understand how a \
decl2 would work. Any help much appreciated!

Regards,
         Colin

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic