The BOOST_PP_LIST_APPEND_D macro appends two lists.  It reenters BOOST_PP_WHILE with maximum efficiency.

Usage

BOOST_PP_LIST_APPEND_D(d, a, b)

Arguments

d
The next available BOOST_PP_WHILE iteration.
a
The first list.
b
The second list.

Remarks

This macro appends two lists.  For example, if a is (1, (2, (3, BOOST_PP_NIL))) and b is (4, (5, BOOST_PP_NIL)), this macro will expand to:
(1, (2, (3, (4, (5, BOOST_PP_NIL)))))

See Also

Requirements

Header:  <boost/preprocessor/list/append.hpp>

Sample Code

#include <boost/preprocessor/arithmetic/dec.hpp>
#include <boost/preprocessor/control/while.hpp>
#include <boost/preprocessor/list/append.hpp>
#include <boost/preprocessor/tuple/elem.hpp>

#define LIST (1, (2, (3, BOOST_PP_NIL)))

#define PRED(d, state) BOOST_PP_TUPLE_ELEM(3, 1, state)

#define OP(d, state) \
   ( \
      BOOST_PP_LIST_APPEND_D( \
         d, BOOST_PP_TUPLE_ELEM(3, 0, state), \
         BOOST_PP_TUPLE_ELEM(3, 2, state) \
      ), \
      BOOST_PP_DEC( \
         BOOST_PP_TUPLE_ELEM(3, 1, state) \
      ), \
      BOOST_PP_TUPLE_ELEM(3, 2, state) \
   ) \
   /**/

#define LIST_MULTIPLY(c, list) \
   BOOST_PP_TUPLE_ELEM( \
      3, 0, \
      BOOST_PP_WHILE( \
         PRED, OP, \
         (BOOST_PP_NIL, c, list) \
      ) \
   ) \
   /**/

LIST_MULTIPLY(3, LIST)
   // expands to (1, (2, (3, (1, (2, (3, (1, (2, (3, BOOST_PP_NIL)))))))))

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)