Boost logo

Boost :

From: Josh Dybnis (jdybnis_at_[hidden])
Date: 2003-06-26 09:49:58

Is there interest in adding support for variable length argument lists
to the preprocessor library.

Variable length argument lists can be used in place of all the existing
data structures (i.e lists, sequences, tuples, and arrays). I've put
together a complete set of operations on variable length argument
lists, including iteration, folds, transform, etc.

The nice thing about the implementation is that it is layered on-top of
the existing BOOST_PP _ macros like BOOST_PP_WHILE. So it doesn't
require modifications to the existing library, and none of the
definitions are more that a few lines long. All the functions live in
the namespace BOOST_PP_VA_.

Here is an example of some of the definitions:

/* constructors for the old preprocessor data structures */
#define BOOST_PP_VA_TUPLE(...) (__VA_ARGS__)

#define BOOST_PP_VA_ARRAY(...) \
    (BOOST_PP_VA_SIZE(__VA_ARGS__), (__VA_ARGS__))

#define BOOST_PP_VA_SEQ(...) \

#define BOOST_PP_VA_LIST(...) \

#define BOOST_PP_VA_LIST_OP(a, b) (b, a)

BOOST_PP_VA_ARRAY(a, b, c) === (3, (a, b, c))
BOOST_PP_VA_SEQ(a, b, c) === (a)(b)(c)
BOOST_PP_VA_LIST(a, b, c) === (a, (b, (c, BOOST_PP_NIL)))

I've put the rest of the implementation at

Of course this requires compiler support of the C99 __VA_ARGS__

-Josh Dybnis

Boost list run by bdawes at, gregod at, cpdaniel at, john at