Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2006-07-14 06:52:51


On 7/9/06 9:21 AM, "Gennaro Prota" <gennaro_prota_at_[hidden]> wrote:

> On Sat, 08 Jul 2006 19:30:13 -0400, Daryle Walker
> <darylew_at_[hidden]> wrote:
>
>> In what I've read in this thread, I've never seen how to get the total count
>> of elements in a multi-dimensional array. (I just seen how to get the count
>> of a particular dimension.)
>
> I never thought about this (or needed it). Did you?

No, I haven't considered or needed this either. I thought that the OP
wanted a total element count, and no one in this thread actually answered
that request. (They only considered the element count for a single
dimension, where the "kewl" part was allowing any dimension to be measured.)

Since every object of a multi-dimensional array is packed together, a total
count could help in pointer-iterating the entire array as a single
one-dimensional pass. The total count would help determine the end pointer,
the beginning pointer would be made by reinterpret_cast-ing the address of
the first element of the outermost array to an address of the first deep
element. (They're the same type for a one-dimensional array, of course.)

> If there's consensus on introducing it I only see two problems:
>
> * choosing a good name :)
> * making it work on non-conforming compilers
> (I have to say of all compilers I tried my straightforward
> implementation on, only gcc could handle it, which is quite
> discouraging for such a trivial piece of code)

I typed that code directly into the e-mail client without ever compiling it.
I am surprised by you saying a lot of compilers can't handle it.

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

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