English 中文(简体)
用模板发送更精确的诊断错误信息?
原标题:More precise diagnostic error messages with templates?

使用模板的编译错误往往模糊不清,而且不容易解开,除非一个真正精通模板。 许多时候专家程序员可能也会被这些错误所困扰。 我相信我们大多数人已经多次感受到了它的困苦。

As I understand the C++ standard only mandates implementations to provide a diagnostic for an ill-formed program but not how or what diagnostic messages shall be provided.
However, are there any guidelines laid out by the Standards committee to overcome this problem of not easily decipherable diagnostics (especially) in case of templates. Has this ever even come up for a discussion? Also, are the mainstream implementations doing something about or have planned about this issue?

The question is quite open ended for discussion but with the SO C++ community being one of the most active C++ communities I am sure someone somewhere must have at least some idea of this. Also, a few of Standards committee members (I know) actively participate on the C++ tag, I am hoping they might have some information on this if et al.

最佳回答

你在问两个不同的问题

首先,是的,主流实施正在做一些事情。 它可能不是g++或 msvc 的最高优先, 但并不是唯一的主流实施。 它也是家族背后的设计目标之一( 见< a href="http://clang.llvm.org/diagnostics.html> http://clang.llvm.org/diagnostics.html ), 至少在某个时候 Intel 列出更好的模板错误作为 ic++ 的销售点 。

其次,标准委员会中的人详细讨论了这一点,并大多同意,概念是答案的一个重要部分,这实际上意味着,由于概念已从C++11标准中删除,概念被推迟到未来。

问题回答

这绝对是一个问题,特别是当人们开始用元类做棘手的事情时。我知道的唯一有助于略微解决问题的工具是stlfilt ,它“简化和/或修改长长的C++错误和警告信息,重点是STL相关诊断”。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签