3 ms·
The only time I've found it useful is making macros that expect an array a little safer in C++. For example: #define count(array) (sizeof(array) / sizeof(
by bodyfour 10y ago
The only time I've found it useful is making macros that expect an array a little safer in C++. For example:
#define count(array) (sizeof(array) / sizeof(0[array]))
...will conveniently cause a compile error if you accidentally pass in a std::vector instead of an array.
- jasode 10y agoThanks for the heads up. Not suprisingly, a related stackoverflow q&a mentions that macro and also another more convoluted one from Chromium that protects against accidental pointers being passed: http://stackoverflow.com/a/1598827 http://stackoverflow.com/a/1598827