Boost.Preprocessor question

I am initializing an array like: unsigned char tmp[256]={0, 1, 2, 3, ...} I feel like this is something Boost.Preprocessor could do for me, but am unable to find out how. Anyone know? -- Cory Nelson http://www.int64.org

-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Cory Nelson
I am initializing an array like:
unsigned char tmp[256]={0, 1, 2, 3, ...}
I feel like this is something Boost.Preprocessor could do for me, but am unable to find out how. Anyone know?
#include

-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Paul Mensonides
#include
#define index(z, n, _) n
unsigned char tmp[256] = { BOOST_PP_ENUM(256, index, ~) };
#undef index
(Note, however, that you can't go any higher than 256 repetitions.)
More specifically, the library cannot _directly_ generate more than 256 repetitions in one pass. You can do something like this, for example: #define index(z, n, offset) n + offset unsigned char tmp[512] = { BOOST_PP_ENUM(256, index, 0), BOOST_PP_ENUM(256, index, 256) }; #undef index Regards, Paul Mensonides
participants (2)
-
Cory Nelson
-
Paul Mensonides