2013年(12)
分类: C/C++
2013-03-27 11:23:16
原文地址:求传入函数中的数组长度 作者:zhm_sunboy
typedef unsigned char byte_t;
template
struct size_v1{
byte_t c[N];
};
template
size
#define dimensionof_v1(x) sizeof(array_size(x).c)
template
byte_t (&dimen(T (&a)[N]) )[N];
#define dimmensionof_v2(x) sizeof(dimen(x))
更简单的实现
template
struct SIZE{
static const int cnt = N;
};
template
/*
cout << sizeof(arr) / sizeof(T) << endl;//work well
struct SIZE
cout << s.cnt << endl;
*/
return SIZE
}