参考https://stackoverflow.com/questions/1005476/how-to-detect-whether-there-is-a-specific-member-variable-in-class中的解决方案,利用decltype, 模板多态,std::false_type, std::true_type快速判断是否有某个名称的成员变量
template <typename T, typename = int>
struct HasX : std::false_type { };
template <typename T>
struct HasX <T, decltype((void) T::x, 0)> : std::true_type { };
struct A { int x; };
struct B { int y; };
// 有 HasX<A>::value == true and HasX<B>::value == false
后续要求,如果struct存在该变量则对其进行赋值。
如果直接出现object.para的形式,HasX<B>::value == false的情况下会报编译错误
因此考虑通过模板多态的方式,在HasX
#define DEFINECHECKPARAM(ParName, ParType) \
template <typename T, typename U = int> \
struct H