array_size

Given an array type, you can get the size of the array with array_size.

The code fragment array_size<type>::value will only compile if type is an array. It won't compile if type is a union, struct or class.

Listing: Example usage of array_size
typedef int Array[10];
size_t n = array_size<Array>::value;

n has the value of 10.