An array is a data structure consisting of a two-element tuple.  The first element is the number of elements in the array.  The second element is another tuple of the elements in the array.  For example,
(3, (a, b, c)) an array of 3 elements--a, b, and c.
The primary strength of arrays is that they store their own size.  Because of this, access to elements does not require the size.  It only requires that an element exists at a certain index.
This allows macro parameters to be variable in size and allows data states to change size without the user explicitly keeping track of the size independently.

An array can be empty and have no elements. An empty array has a 0 size. The notation for an empty array is '(0,())'.

With variadic macro support a tuple has all of the functionality as an array, knows its own size, and is easier syntactically to use. Because of that an array should be used, as opposed to a tuple, only if your compiler does not support variadic macros. The only advantage an array has over a tuple is that an array can be empty while a tuple always has at least one element and therefore can never have a size of 0.

Elements of an array can be extracted with BOOST_PP_ARRAY_ELEM, an array's size can be extracted with BOOST_PP_ARRAY_SIZE, and an array can be converted to the more primitive tuple data structure with BOOST_PP_ARRAY_DATA.


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