请问下这个模板的语法是啥。。

NYN NYN 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区


template<class S, class T>
struct SameClass
{
template<class Identical, Identical> //A: 这个一般都是 typename A, typename B吧。。这样写有啥特殊语法么?
struct type_match;

template<class _1>
static char (& func(
type_match< T& (_1::*)(const _1&), &_1::operator => *) )[1]; // 这个必须用这种写法才能有效果,请问下这种写法的含义是啥。。跟之前(A:)的有啥匹配关系?

template<class >
static char (& func(...))[2];

static bool const value = sizeof(func<S>(0)) == 1;
};

template<class c1, class c2>
bool IsSameClassAs() { return SameClass<c1,c2>::value == 1; }

...全文
评论 18
收藏 已收藏
分享
返回顶部
NYN
模式及实现 5,528 成员 4,167 内容