Boost logo

Boost Users :

Subject: Re: [Boost-users] BOOT_PP_REPEAT simple nesting problem
From: Hickman, Steve (AdvTech) (Steve.Hickman_at_[hidden])
Date: 2014-09-22 12:02:34


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_at_[hidden]]
Sent: Saturday, September 20, 2014 6:36 AM
To: Boost-users_at_[hidden]
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 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