MSVC8 的简洁错误消息:有没有办法更明确?
我已经
Baz<Foo, Bar> blah_blah(Foo const& f, Bar const& b)
{ return Baz<Foo, Bar>(f, b); }
得到了这个错误:
error C2893: Failed to specialize function template 'Baz<Foo, Bar> blah_blah(Foo, Bar)'
with the following template arguments:
'ConcreteFoo'
'ConcreteBar'
这绝对是无用的,并且可能会花费我很多时间来调查这个问题(涉及的模板非常多,并且 ConcreteFoo
和 ConcreteBar
本身毛茸茸的模板)。
我想知道 ConcreteFoo
和 ConcreteBar
缺少哪些类型/成员对象/成员函数,这会阻止 Baz
模板的实例化。
有没有办法解决 Visual C++ 2005 的这种愚蠢的错误报告?
编辑(相关):Baz、ConcreteFoo 和 ConcreteBar 是这样的:
template <typename T, typename U, bool = f(T, U), int = g(T, U), etc>
struct Baz
{ ... }
并且有相当多的部分专业化。我知道哪一个是从编译器消息中获取的。另外,函数 f 和 g 是丑陋的元编程东西,我相信我的问题来自那里: f 或 g 之一不能产生正确的结果。 ConcreteFoo 或 ConcreteBar 中一定缺少某种类型/静态成员,但我不知道是哪一个。
另外,我很难抓住项目的相关部分,并编写一个副项目进行测试,我想要一些更“内联”的东西。
I have
Baz<Foo, Bar> blah_blah(Foo const& f, Bar const& b)
{ return Baz<Foo, Bar>(f, b); }
and I get this error:
error C2893: Failed to specialize function template 'Baz<Foo, Bar> blah_blah(Foo, Bar)'
with the following template arguments:
'ConcreteFoo'
'ConcreteBar'
which is definitely useless and will likely take me a lot of time investigating the issue (templates involved are quite hairy, and ConcreteFoo
and ConcreteBar
are themselves hairy templates).
I'd like to know what types/members objects/member functions are missing from ConcreteFoo
and ConcreteBar
which prevent instantiation of the Baz
template.
Is there a way to work around this idiotic error reporting from Visual C++ 2005 ?
EDIT (relevant): Baz, ConcreteFoo and ConcreteBar are like this:
template <typename T, typename U, bool = f(T, U), int = g(T, U), etc>
struct Baz
{ ... }
and there are quite a few partial specializations. I know which one is taken from the compiler message. Also, the functions f and g are ugly ugly meta programming stuff, and I believe my problem comes from there: there is one of f or g which does not yield the right result. There must be some type / static member missing from either ConcreteFoo or ConcreteBar, and I don't know which one.
Also, it is difficult for me to just grab the relevant parts of the project, and write a side project for testing, I'd like something more "inline".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ConcreteFoo 和 ConcreteBar 是模板还是类?那么您正在尝试的是专业化还是部分专业化?
当我们看不到完整的失败示例时,很难判断。
顺便问一下,在责怪编译器之前,您是否在另一个编译器(例如 comeau tryitout)上尝试过您的代码?
ConcreteFoo and ConcreteBar are templates or classes? And so is it a specialization or partial-specialization you are trying?
It's difficult to tell when we can't see a full failing example.
By the way have you tried your code on another compiler like comeau tryitout, before you blame the compiler?