- 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))
-
-
- ...is 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.
-
-
- 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.
-
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))
+
...is 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.
+
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.
+
+ 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.
A tuple is a simple comma-separated list of elements inside
+ parenthesis. For example,
+
(a, b, c)
+
...is a tuple of 3 elements--a, b, and
+ c.
+
Tuples are fast and easy to use. With variadic macro
+ support it is not necessary to know the size of a tuple; without
+ variadic macro support all access to tuples requires
+ knowledge of its size. Use a tuple instead of an array if
+ your compiler supports variadic macros, since a tuple has all of
+ the functionality as an array and is easier syntactically to use.
+
Elements of a tuple can be extracted with BOOST_PP_TUPLE_ELEM.
+