I am learning/reading a bit of openGL. I am currently following the tutorials from http://www.arcsynthesis.org/gltut/ . The program has a macro which is used for array length. I know array length is counted as (sizeof( array ) / (sizeof( array[0] ).
But the code has some additional stuff so the final macro is :
#define ARRAY_COUNT( array ) (sizeof( array ) / (sizeof( array[0] ) * (sizeof( array ) != sizeof(void*) || sizeof( array[0] ) <= sizeof(void*))))
I am unable to understand why is it being multiplied by a bool.
char *,sizeof(arr[0]) <= sizeof(void *)must be true, so it will still count. Considering this is C++, you can write aconstexprfunction to achieve the same thing, or a regular one to have the result at runtime. Of course you could also just usestd::arrayorboost::array.