An array type is denoted as T[n]
where T
is the element type and n
is a positive size, the number of elements in the array. The array type is a product type of the element type and the size. If one or both of those ingredients differ, you get a distinct type:
#include<type_traits>static_assert(!std::is_same<int[8],float[8]>::value,"distinct element type");static_assert(!std::is_same<int[8],int[9]>::value,"distinct size");
Note that the size is part of the type, that is, array types of different size are incompatible types that have absolutely nothing to do with each other. sizeof(T[n])
is equivalent to n * sizeof(T)
.