不同的模板错误格式在GCC? [英] Different template error format in GCC?

查看:196
本文介绍了不同的模板错误格式在GCC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GCC对某些模板错误消息有非常详细的格式:

GCC has a very verbose format for certain template error messages:

... some_class<A,B,C> [with int A = 1, int B = 2, int C = 3]

它显示如下:

... some_class<1,2,3>


推荐答案

template<int A, int B> class X {
  void f();
};

template<int A> class X<A, 2> {
  void f();
};

int main() {
  X<1, 2>().f();
  X<2, 1>().f();
}

GCC输出

m.cpp: In function 'int main()':
m.cpp:6:12: error: 'void X<A, 2>::f() [with int A = 1]' is private
m.cpp:10:19: error: within this context
m.cpp:2:12: error: 'void X<A, B>::f() [with int A = 2, int B = 1]' is private
m.cpp:11:19: error: within this context

如果只是说 X <1,2> X < ; 您将失去该诊断包含的重要信息。

If it just said X<1, 2> and X<2, 1> you would lose an important information that this diagnostic contains.

这篇关于不同的模板错误格式在GCC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆