sizeof(T*)
is the size of a pointer, not the size of whatever sequence of objects it points to.
If you want the number of elements of an array, either use a macro at the place where it's still an array, use a more friendly array type (std::array
), or template it:
template <typename T, size_t N>
size_t array_count(T const (&)[N]) {
return N;
}