The BOOST_PP_REPEAT_FROM_TO macro represents a fast horizontal repetition construct.

Usage

BOOST_PP_REPEAT_FROM_TO(first, last, macro, data)

Arguments

first
The lower bound of the repetition.  Valid values range from 0 to BOOST_PP_LIMIT_MAG.
last
The upper bound of the repetition. Valid values range from 0 to BOOST_PP_LIMIT_MAG.
macro
A ternary operation of the form macro(z, n, data).  This macro is expanded by BOOST_PP_REPEAT with the next available repetition depth, the current repetition number, and the auxiliary data argument. 
data
Auxiliary data passed to macro.

Remarks

This macro expands to the sequence:
macro(z, first, data) macro(z, first + 1, data) ... macro(z, last - 1, data)
The number of repetitions (i.e. last - first) must not exceed BOOST_PP_LIMIT_REPEAT.
The z value that is passed to macro represents the next available repetition dimension.  Other macros that have _Z suffix variants internally use BOOST_PP_REPEAT--for example, BOOST_PP_ENUM_PARAMS and BOOST_PP_ENUM_PARAMS_Z.  Using these _Z versions is not strictly necessary, but passing the z value (that is passed to macro) to these macros allows them to reenter BOOST_PP_REPEAT with maximum efficiency.
To directly use this z value, rather than simply passing it to another macro, see BOOST_PP_REPEAT_FROM_TO_z.
Previously, this macro could not be used recursively inside BOOST_PP_REPEAT.  This limitation no longer exists, as the library can automatically detect the next available repetition depth.
This macro also uses BOOST_PP_WHILE.  Because of this, there are also two variants of this macro for ideal reentrance into BOOST_PP_WHILE, BOOST_PP_REPEAT_FROM_TO_D and BOOST_PP_REPEAT_FROM_TO_D_z.

See Also

Requirements

Header:  <boost/preprocessor/repetition/repeat_from_to.hpp>

Sample Code

#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>

#define DECL(z, n, text) BOOST_PP_CAT(text, n) = n;

BOOST_PP_REPEAT_FROM_TO(5, 10, DECL, int x)
   /*
      expands to:
      int x5 = 5; int x6 = 6; int x7 = 7;
      int x8 = 8; int x9 = 9;
   */

© Copyright Housemarque Oy 2002
© Copyright Paul Mensonides 2002

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)