全部博文(346)
分类: C/C++
2008-09-02 09:12:20
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
}