The BOOST_PP_RELATIVE_ITERATION macro expands to the iteration value of a file-iteration depth relative to the current depth.

Usage

BOOST_PP_RELATIVE_ITERATION(i)

Arguments

i
The relative depth of the frame whose iteration value is to be retreived.  Valid values range from 0 to BOOST_PP_ITERATION_DEPTH() - 1.

Remarks

This macro is only valid when a file-iteration is in progress.
The argument i is interpreted as the number of frames outward from the current frame.  Therefore, BOOST_PP_RELATIVE_ITERATION(0) is equivalent to BOOST_PP_ITERATION().

Requirements

Header:  <boost/preprocessor/iteration/iterate.hpp>

Sample Code

// file.h
#if !BOOST_PP_IS_ITERATING

   #ifndef FILE_H_
   #define FILE_H_

   #include <boost/preprocessor/iteration/iterate.hpp>

1st iteration:
   #define BOOST_PP_ITERATION_PARAMS_1 (4, (0, 3, "file.h", 0x0001))
   #include BOOST_PP_ITERATE()

2nd iteration:
   #define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 10, "file.h", 0x0002))
   #include BOOST_PP_ITERATE()

   #endif

#elif BOOST_PP_ITERATION_DEPTH() == 1 \
   && BOOST_PP_ITERATION_FLAGS() == 0x0001 \
   /**/

   --
   #define BOOST_PP_ITERATION_PARAMS_2 (3, (1, 10, "file.h"))
   #include BOOST_PP_ITERATE()

#elif BOOST_PP_ITERATION_DEPTH() == 1 \
   && BOOST_PP_ITERATION_FLAGS() == 0x0002 \
   /**/

   --
   #define BOOST_PP_ITERATION_PARAMS_2 \
      (3, (1, BOOST_PP_ITERATION(), "file.h")) \
      /**/
   #include BOOST_PP_ITERATE()

#elif BOOST_PP_ITERATION_DEPTH() == 2 \
   && BOOST_PP_FRAME_FLAGS(1) == 0x0001 \
   /**/

   --
   #define BOOST_PP_ITERATION_PARAMS_3 \
      (3, (1, BOOST_PP_ITERATION(), "file.h")) \
      /**/
   #include BOOST_PP_ITERATE()

#else // used by both

   previous: BOOST_PP_RELATIVE_ITERATION(1)
   current: BOOST_PP_ITERATION()

#endif

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)