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.

http://dpaste.dzfl.pl/481e26b6

It's quite simple.
Macros in C++, should be replaced with their successor - templates. In case of D, we haven't got macros per se, so we need to use template.

In example above I just used template'd function.

Reply via email to