3 ms·
-Werror-sizeof-pointer-div Or in C++: #include <type_traits> template < typename T, std::size_t N > constexpr std::size_t count_of(const T (&)[N]
by MaulingMonkey 7y ago
-Werror-sizeof-pointer-div
Or in C++:
#include <type_traits>
template < typename T, std::size_t N >
constexpr std::size_t count_of(const T (&)[N]) { return N; }
#define COUNTOF(a) std::integral_constant<std::size_t, count_of(a)>::value
(C++03 friendly versions are entirely possible, but left as an exercise to the reader)