Help translating C/C++ snippet to D

Tongzhou Li zhangsongcui at hotmail.com
Tue Jul 3 02:23:13 PDT 2012


On Tuesday, 3 July 2012 at 02:34:04 UTC, Dustin wrote:
> Hello,
> I'm trying to follow along with a C++ tutorial and translate it 
> to D but I don't know C/C++ well enough to understand this 
> #Define statement:
>
> #define ARRAY_COUNT( array ) (sizeof( array ) / (sizeof( 
> array[0] ) * (sizeof( array ) != sizeof(void*) || sizeof( 
> array[0] ) <= sizeof(void*))))
>
> Can anyone help me understand this and translate it to a D 
> function? Thanks for your time.

Just use this:

> int[123] i;
> writeln(i.length);

> int* p;
> writeln(p.length); // Compile error

Bye!


More information about the Digitalmars-d-learn mailing list