From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2005-10-10 14:32:58
> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Yao Zhen
> I am aware that variadic macros are not in the current C++
> standard. However, it is declared that "the C++
> standardization committee is likely to adopt C99's
> preprocessor extensions for the next version of the C++
> standard." So here is a question about it.
Take a look at Chaos; it supports variadics from the ground up. I'll send you a
> I have though that with the help of variadic macros, it would
> be nolonger necessary for us to povide size of preprocessor
> tuples manually.
It isn't necessary, but it is sometimes more efficient.
> For instance, in fact it is easy to
> implement the BOOST_PP_TUPLE_ELEM macro more clearly as:
> #define TUPLE_ELEM(i, tuple) TUPLE_ELEM_ ## i tuple
> #define TUPLE_ELEM_0(a0, ...) a0
> #define TUPLE_ELEM_1(a0, a1, ...) a1
> #define TUPLE_ELEM_2(a0, a1, a2, ...) a2 #define
> TUPLE_ELEM_3(a0, a1, a2, a3, ...) a3
Except that this will fail if you try to extract the last element of a tuple.
You have to increase the input tuple's size to account for this:
#define TUPLE_ELEM(i, tuple) TUPLE_ELEM_II(i, TUPLE_ELEM_I tuple) \
#define TUPLE_ELEM_I(...) (__VA_ARGS__,,,,,,,,,,,,,,,,,,,,,,,,)
#define TUPLE_ELEM_II(i, tuple) TUPLE_ELEM_ ## i tuple
> However, I failed to think out a way to implement TUPLE_SIZE.
> Is there any way to do this?
Yes. Up to a certain size, this can be a constant time (and fast) operation.
For larger tuples, the size can be calculated with an algorithm.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk