The BOOST_PP_LIST_SIZE_D macro expands to the size of a list.  It reenters BOOST_PP_WHILE with maximum efficiency.

Usage

BOOST_PP_LIST_SIZE_D(d, list)

Arguments

d
The next available BOOST_PP_WHILE iteration.
list
A list whose size is to be calculated.

See Also

Requirements

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

Sample Code

#include <boost/preprocessor/arithmetic/add.hpp>
#include <boost/preprocessor/list/fold_left.hpp>
#include <boost/preprocessor/list/size.hpp>

#define L1 (a, (b, (c, BOOST_PP_NIL)))
#define L2 (x, (y, BOOST_PP_NIL))
#define L3 (p, (q, BOOST_PP_NIL))

#define LIST (L1, (L2, (L3, BOOST_PP_NIL)))

#define OP(d, state, x) \
   BOOST_PP_ADD_D( \
      d, state, \
      BOOST_PP_LIST_SIZE_D(d, x) \
   ) \
   /**/

BOOST_PP_LIST_FOLD_LEFT(OP, 0, LIST) // expands to 7

© 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)