如果这是可能的,则可以索引到可变参数模板参数包而无需递归。然而,海湾合作委员会是拒绝接受我的部分专业化 here:
template <int I, typename List>
struct element_impl;
template <typename... TL, int... IL, typename T, int I, typename... TR, int... IR>
struct element_impl<I, typelist<pair<TL,IL>..., pair<T,I>, pair<TR,IR>...>> {
typedef T type;
};
prog.cpp:在 ' 的实例化中element<0, typelist<int, double, char,
float, long int> >
':
prog.cpp:52:34:从这里实例化
prog.cpp:47:79:错误:无效使用不完整类型'struct element_impl<0, typelist<pair<int, 0>, pair<double, 1>, pair<char, 2>, pair<float, 3>, pair<long int, 4> >
'
GCC 是否有错误,或者我是否忽略了可变参数模板的某些限制?