必须是 C++标准库可以用 C++ 实现吗?
- 符合 C++ 标准库的实现必须用 C++ 实现吗?
- 如果不是,是否允许做纯 C++ 和 C++ 中无法完成的神奇事情?标准库和一些实现定义的行为?
- 我知道有依赖扩展的并行实现(至少在 C++11 之前),但它们真的符合吗?
- 我在标准中找不到任何要求,但也许我今天的标准能力很弱
- Must a conforming C++ Standard Library Implementation be implemented in C++?
- If not, is it allowed to do magic things that are not doable in pure C++ & Standard Library & some implementation defined behaviour?
- I am aware that there are parallel implementations that rely on extensions (in pre C++11 at least), but are they really conforming?
- I couldn't find any requirement in the standard, but maybe my standard-fu is weak today
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根本没有要求标准 C++ 库(或与此相关的标准 C 库)如何实现。库需要实现的只是实现文档化和指定的接口。如何做到这一点完全取决于实施。部分标准库通常由编译器以某种神奇的方式实现,并且在 C++2011 中,有几个接口实际上无法使用标准 C++2011 语言设施来实现!对于
中的某些特征来说,这主要是正确的,但还有其他情况。仅供参考:C++ 是如何实现的以及符合标准的实际含义非常模糊。相关条款是 1.4 [intro.compliance]。它仅涉及发出的诊断以及程序必须执行的操作,但是受到资源限制。
There is no requirement at all how the standard C++ library (or the standard C library for that matter) is implemented. All the library needs to achieve is to implement the documented and specified interface. How this is done is entirely up to the implementation. Part of standard libraries are often implemented by the compiler in some magic way and in C++2011 there are several interfaces which actually cannot be implemented using standard C++2011 language facilities! Primarily this is true for some of the traits in
<type_traits>
but there are other things.Just for the reference: how C++ is implemented and what it actually really means to conform to the standard is held extremely vague. The relevant clause is 1.4 [intro.compliance]. It merely speaks about diagnostics being issued and what a program has to do, constraint to resource limitations, however.
不。
实际上,标准甚至规定
#include
(例如)可以简单地导入预存储的 AST,而根本不引用文件。
No.
Actually, it is even prescribed by the Standard that
#include <map>
(for example) could simply import a pre-stored AST and not refer to a file, at all.完全不需要,只是接口需要是C++。
Not at all, only the interface needs to be C++.