在哪里可以找到“已采取”的列表?标准库中的标识符
由于当前 C/C++ 库(如 STL、Win32、Boost、posix 等)的规模较大,出现了哪些标识符有问题的问题。即使有了命名空间,在设计一个与现有库协同工作的新库时,能够选择不与其他库最常用的标识符冲突的标识符也是很好的。
至少对于 C++ 标准库(包括 0x)应该有可用的列表。可以合理地认为有人为此目的开发了一个工具,该工具读取一组头文件并创建按名称空间排序的所有名称的列表。有谁知道这样的工具吗?该工具最好读取目录树中的所有标头,而不是仅读取特定 cpp 文件 #included 的标头。
With the large size of current C/C++ libraries like STL, Win32, Boost, posix etc. the question of what identifiers are problematic arises. Even with namespaces it is nice to be able to select identifiers which don't clash with the most used identifiers of other libraries when desiging a new library designed to work togheter with existing ones.
At least for the C++ standard libraries (including 0x) there should be listings available. It would be reasonable to think that someone has done a tool for this purpose, which reads a set of header files and creates a list of all names ordered by namespace. Anyone who knows of such a tool? The tool should preferably read all headers in a directory tree rather than only those #included by a particular cpp file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我意识到很多图书馆都这样做,但这种尝试从根本上来说是错误的。
不要将标识符设计得不冲突,而应使其清晰、简短且具有描述性。这些应该是唯一的标准。
由于命名空间,标识符冲突已经解决了。如果使用得当,名称冲突根本就不会发生。
I realize that quite a few libraries do that but this attempt is fundamentally misguided.
Don’t design your identifiers so that they don’t clash, design them so that they are clear, short, and descriptive. These should be the only criteria.
Identifier clash is a solved problem, thanks to namespaces. Properly used, name clash simply doesn’t arise.
使用egrep怎么样? [咕咕咕咕获得30个字符]
How about using egrep? [Mumble mumble to get 30 characters]