I like returning void because it allows more expressive code that says (at least to me) 'return whatever this function returns, it'll do the rest of the job, I'm done'. This is just a case when this happens to be 'nothing'(void) so just the 'it'll do the rest of the job, I'm done' part is communicated.
I think it's in C++ because of some templates motivated reason.
Also it might let optimizer use a tail call easier (because compiler/optimizer sees that 'I'm done, let this function take over' part too instead of looking forward, seeing if there is a break after call, if the switch has nothing after itself and so on).
Another trick:
C++ syntax to take a reference to an array. It has use in a neat trick (see below) and restricts input to just right size arrays but it's horrible in itself already:
void takearr(int (&arr)[2]) {}
It will NOT work without () around &arr, it'll think you want to pass in array of references then.. at least that's what GCC says...
I myslef am not 100% sure what the f... is going on already. Let's step it up a notch (this is from Google Chrome source, at least that's what the place I found it in by googling says, I just googled for 'Chrome array size macro template' and similar, it's kind of 'common' trick that has few variants):
template <typename T, size_t N>
char (& ArraySizeHelper (T (& array) [N])) [N];
#define arraysize(array) (sizeof (ArraySizeHelper (array)))
It gets the size of array properly, protects against just passing in a pointer and is a compile constant too... Yes, the function will never be defined so it can't be really called.
Yes, this function takes and returns a reference to N sized arrays. Looks wonderful, doesn't it? If not, I think you can omit the name of input param:
template <typename T, size_t N>
char (& ArraySizeHelper (T (&) [N])) [N];
#define arraysize(array) (sizeof (ArraySizeHelper (array)))
Much better now...