Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2006-06-28 08:07:17


On Wed, 28 Jun 2006 00:05:47 -0400, David Abrahams
<dave_at_[hidden]> wrote:

>Gennaro Prota <gennaro_prota_at_[hidden]> writes:
>
>> The real somersaults begin when you want the multidimensional case :)
>> Here's what came out:
>
>I'm pretty sure it's easier than this. IIRC, the macro can still do
>the old sizeof(a)/sizeof(a[0]) trick; it just needs to add something
>that will cause an error if a is not an array.

Sure that's easy for monodimensional arrays. When you write something
like, for instance,

 COUNT_OF_N(3, x)

though, it's not enough to check that x is an array. It shall be an
array, x[0] shall be an array, x[1] and x[2] shall be arrays. I can
imagine implementing it with some pp-lib iteration which automatically
generates

 sizeof(x[0])/sizeof(x[0][0])
 sizeof(x[0][0])/sizeof(x[0][0][0])
 sizeof(x[0][0][0])/sizeof(x[0][0][0][0])

up to a given limit, but I'm not sure it can *reliably* be done with
templates only. Suggestions are welcome. During my attempts I came out
with some simpler solutions but they ICEd as soon as I invoked the
macro in non trivial expressions. This is the solution which seemed
more robust so far.

FWIW, my opinion is that for VC6 we should only support the
1-dimensional case.

--Gennaro.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk