先旨声明,调试这里的代码用vc2008会顺利很多,template就是把编译器的功能发挥到最大了,所以几行代码卡你十几秒乃寻常事,为了让程序够cool够rock,其余的,随它去。
so, check it out ...
template<typename T>
class IsClass
{
typedef char one;
typedef struct { char x[2]; }two;
template<typename T> static one test(int T::*);
template<typename T> static two test(...);
public:
enum { Yes = (sizeof(test<T>(0)) == sizeof(one)) };
enum { No = !Yes};
};
typedef char True;
typedef struct {char x[2];} False;
template<typename T> True IsPtr(T*);
False IsPtr(...);
#define ISPTR(f) (sizeof(IsPtr(f))==sizeof(True))
3309



被折叠的 条评论
为什么被折叠?



