typedef char T_must_be_complete_type[sizeof(T) == 0 ? -1 : 1];
T_must_be_complete_type dummy; (void) dummy;
delete value_;
value_ = NULL;
检查是否未完成类型
例如
class A;
extern A a;
========================================================
template<typename T>
struct has_xxxx
{
template <typename C> static char test(decltype(&C::xxxx));
template <typename C> static int32_t test(...);
const static bool value = sizeof(test<T>(0)) == 1;
};
检查类T是否有某个成员函数
========================================================
template<typename T1,typename T2>
struct is_same
{
const static bool value = false;
};
template<typename T1>
struct is_same<T1,T1>
{
const static bool value = true;
}
检查两个类型是否相等
网友评论