【发布时间】:2017-12-07 00:59:18
【问题描述】:
在 C++ 标准 [temp.over.link] 中,解释了函数模板等价性的确定不应涉及编译器的“英勇努力”。
例如,C++ 标准提出了这样的建议:
// guaranteed to be the same
template <int I> void f(A<I>, A<I+10>);
template <int I> void f(A<I>, A<I+10>);
// guaranteed to be different
template <int I> void f(A<I>, A<I+10>);
template <int I> void f(A<I>, A<I+11>);
// ill-formed, no diagnostic required
template <int I> void f(A<I>, A<I+10>);
template <int I> void f(A<I>, A<I+1+2+3+4>);
这条规则是否也适用于涉及元编程的案例,如下例所示?
template<class T>
struct t_{
using type = T;
};
//ill-formed or different?
template<class T> T f(T);
template<class T> typename t_<T>::type f(T);
【问题讨论】: