Boost logo

Boost Users :

Subject: [Boost-users] BOOST_PP_ENUM_z
From: er (er.ci.2020_at_[hidden])
Date: 2011-05-17 12:46:11


Could someone please help clarify the meaning of the _z extension?

In what situation should one use BOOST_PP_ENUM_z rather than BOOST_PP_ENUM?

Usage

BOOST_PP_ENUM_ ## z(count, macro, data)

Arguments

z
     The next available BOOST_PP_REPEAT dimension.

http://www.boost.org/doc/libs/1_33_1/libs/preprocessor/doc/ref/enum_z.html

Examples:

#include <boost/preprocessor/arithmetic/inc.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>

#define MACRO(z, n, _) \
    template< \
       BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(n), class T) \
> class X ## n { \
       /* ... */ \
    }; \
    /**/

BOOST_PP_REPEAT(2, MACRO, nil)

#define MACRO1(z, n, _) \
    template< \
       BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), class T) \
> class Y ## n { \
       /* ... */ \
    }; \
    /**/

BOOST_PP_REPEAT(2, MACRO1, nil)

int main (int argc, char * const argv[]) {
     typedef X0<int> x0;
     typedef X1<int, int> x1;

     typedef Y0<int> y0;
     typedef Y1<int, int> y1;

     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