写了一个 package<_Tps...> 类(类似于 std::tuple<_Tps...>),并添加了一个成员函数 get<_cnt>(void) 表示获取第 _cnt 个元素,代码如下:
typename cntter_type<0, _Tpf, _Tps...>::restype& __get(__AHA__<0>) {
return _fir;
}
template<const unsigned _cnt> typename cntter_type<_cnt, _Tpf, _Tps...>::restype& __get(__AHA__<_cnt>) {
return _els.__get(__AHA__<_cnt - 1>());
}
typename cntter_type<0, _Tpf, _Tps...>::restype __get(__AHA__<0>) const {
return _fir;
}
template<const unsigned _cnt> typename cntter_type<_cnt, _Tpf, _Tps...>::restype __get(__AHA__<_cnt>) const {
return _els.__get(__AHA__<_cnt - 1>());
}
template<const unsigned _cnt> typename cntter_type<_cnt, _Tpf, _Tps...>::restype& get() {
return __get(__AHA__<_cnt>());
}
template<const unsigned _cnt> typename cntter_type<_cnt, _Tpf, _Tps...>::restype get() const {
return __get(__AHA__<_cnt>());
}
cntter_type<_cnt, _Tps...>::restype 获取第 _cnt 个类型,__AHA__<_cnt> 是空类(用以指示)。
但是在用指针时发生奇异事件(某类内代码):
static unsigned res;
static const package<_Tps...> *ptr;
template<const long long _key> class info {
public:
void operator () () const {
res = (
res * 149ULL % _Mod + compress<typename cntter_type<_key, _Tps...>::restype, _Mod>()(ptr -> get<_key>(void())) * 67ULL % _Mod
) % _Mod;
}
};
在 ptr -> get<_key>(void()) 这里出错了,说是
Invalid operands of types '<unresolved overloaded function types>' and 'long long int' to binary 'operator <'
(或者说是把 ptr -> get<_key>(void()) 当成 ((ptr -> get) < _key) > void() 了),
模板变成了 operator < 及 operator >。
求助如何使这一段通过编译