template <typename T,int len> size_t arraylen(T (&arr)[len]) { return len; } int main() { int a[] = {1,2,3,4,5,6}; printf("array length: %d",arraylen(a)); return 0; }