模板名称歧义:G++ vs clang++
前提:g ++和clang ++是已知有时不符合或不符合应用用于依赖名称的模板删除的规则。
在这方面,以下代码 compiles 在g ++下,但不在clang ++下 clang ++:
template<class T1>
struct A {
template <class T2>
class Anested {
public:
typedef A<T2> Other;
};
};
template <class T>
struct B {
typedef B<T> Myself;
typedef typename T::Anested<Myself>::Other Other; //clang++ requires "template" before "Anested" to compile
};
int main() {
B<A<void>> b;
}
clang ++在这种情况下合规(不是吗?),但我想知道在这种语句中,“模板”关键字实际上是多余的。如果不是多余的,您能否举一些例子来证明扣除规则后面是G ++是有缺陷的吗?
Premise: g++ and clang++ are known to be sometime discordant or not compliant on applying the rules for template disambiguation for dependent names.
In this regard, the following code compiles under g++ but does not under clang++:
template<class T1>
struct A {
template <class T2>
class Anested {
public:
typedef A<T2> Other;
};
};
template <class T>
struct B {
typedef B<T> Myself;
typedef typename T::Anested<Myself>::Other Other; //clang++ requires "template" before "Anested" to compile
};
int main() {
B<A<void>> b;
}
clang++ is compliant in this case (isn't it?), but I am wondering whether the "template" keyword is actually redundant in this kind of statement. If it is not redundant, could you please make some examples to prove that the deduction rule followed by g++ is flawed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论