3 ms·
Does this work at compile-time? One of the uses for countof is (somewhat ironically) doing a enum->string table where you want to enforce the table gets manual
by kayamon 11y ago
Does this work at compile-time?
One of the uses for countof is (somewhat ironically) doing a enum->string table where you want to enforce the table gets manually updated properly:
enum Color { red, green, blue, num_colors };
const char *color_string[] = { "red", "green", "blue" };
static_assert(countof(color_string) == num_colors);
- tines 11y agoNo, it doesn't, which is why I said this is better implemented with a template :)