title: ARRAYSIZE C++ macro: how does it work?
body: <p>OK, I'm not <em>entirely</em> a newbie, but I cannot say I understand the following macro. The most confusing part is the division with value cast to size_t: what on earth does that accomplish? Especially, since I see a negation operator, which, as far as I know, might result in a zero value. Does not this mean that it can lead to a division-by-zero error?  (By the way, the macro <em>is</em> correct and works beautifully.)</p>
  
  <pre><code>#define ARRAYSIZE(a) \
    ((sizeof(a) / sizeof(*(a))) / \
    static_cast&lt;size_t&gt;(!(sizeof(a) % sizeof(*(a)))))
  </code></pre>