通过模板判断类类型的代码,在vc++2005的问题,各位大大来看看
htqx 2006-12-12 05:50:06 template<class T>
class IsClass {
private:
typedef char One;
typedef struct{char s[2];} Two;
template<class C> static One func( int C::* );
template<class C> static Two func( ... );
public:
//为何在vc++2005如果加上IsClass::就不能通过编译
//error C2783: “IsClass<T>::Two IsClass<T>::func(...)”: 无法为“C”推导 模板 参数
enum { YES = sizeof ( /* IsClass:: */ func<T>(0) ) == 1 };
enum { NO = !YES };
};