GCC正在给我一个"模板参数2无效"我尝试实例化这样的模板时出错(参见using Check
行)。我很好奇我可以在模板参数列表之外使用decltype
获取指向成员的指针,但不在其中(请参阅变量p2
的定义)。事实上,Clang编译了这段代码。这是GCC中的一个错误,或者这个代码实际上是无效的,而Clang只是过于包容?
template <class T, T t> struct checker_template {};
struct S { int n; };
int main() {
S s;
constexpr auto p1 = &S::n;
constexpr auto p2 = &decltype(s)::n;
using Check = checker_template<int S::*, &decltype(s)::n>;
return 0;
}
答案 0 :(得分:0)
答案由T.C.提供。这确实是GCC中的一个错误。