1.4 Implementation compliance [intro.compliance]
1.4 实现遵从性 【总则.遵从性】
The set of diagnosable rules consist of all syntactic and semantic rules in this International Standard except for those rules containing an explicit notation that "no diagnostic is required" or which are described as resulting in "undefined behavior."
可诊断规则的集合包括除了被明确标记为“无需诊断”或描述为导致“未定义行为”的规则外,本国际标准中的所有语法和语义规则。
Although this International Standard states only requirements on C++ implementations, those requirements are often easier to understand if they are phrased as requirements on programs, parts of programs, or execution of programs. Such requirements have the following meaning:
If a program contains no violations of the rules in this International Standard, a conforming implementation shall, within its resource limits, accept and correctly execute3) that program.
If a program contains a violation of any diagnosable rule, a conforming implementation shall issue a least one diagnostic message, except that
If a program contains a violation of a rule for which no diagnostic is required, this International Standard places no requirement on implementations with respect to that program.
虽然本国际标准只是陈述了 C++ 实现的规格,但将它们当作程序,程序片段,程序的执行的规格通常更容易理解。这些规格包含以下意义:
如果程序不违反本国际标准的规则,符合标准的实现应该在其资源限制下,接受并正确执行3)这个程序。
如果程序违反了任何可诊断规则,符合标准的实现应该给出至少一条诊断消息,除非
如果程序违反了无需诊断的规则,对于这个程序本国际标准将不要求实现实施任何规格。
For classes and class templates, the library clauses specify partial definitions. Private members (clause 11) are not specified, but each implementation shall supply them to complete the definitions according to the description in the library clauses.
对于类和模板类,库章节指定了它们的部分定义。虽然没有具体指定,但每个实现都应该提供私有成员(章节11)以按照标准库章节的描述将类和模板类的定义完成。
For functions, function templates, objects, and values, the library clauses specify declarations. Implementations shall supply definitions consistent with the descriptions in the library clauses.
对于函数,函数模板,对象和值,库章节规定了它们的声明。每个实现都应该提供与标准库章节的描述一致的定义。
The names defined in the library have namespace scope (7.3). A C++ translation unit (2.1) obtains access to these names by including the appropriate standard library header (16.2).
在标准库中定义的名字具有名字空间作用域(7.3)。C++ 编译单元(2.1)可通过包含相应的标准库头文件(16.2)来获取访问这些名字的能力。
The templates, classes, functions, and objects in the library have external linkage (3.5). The implementation provides definitions for standard library entities, as necessary, while combining translation units to form a complete C++ program (2.1).
标准库中的模板,类,函数和对象具有外部连接(3.5)。当将编译单元合成一个完整 C++ 程序(2.1)时,实现应该根据需要提供标准库实体的定义。
Two kinds of implementations are defined: hosted and freestanding. For a hosted implementation, this International Standard defines the set of available libraries. A freestanding implementation is one in which execution may take place without the benefit of an operating system, and has an implementation-defined set of libraries that includes certain language-support libraries (17.4.1.3).
本国际标准定义了两类实现:寄生实现和原生实现。本国际标准为寄生实现定义了一组可用的库。原生实现中的程序执行没有操作系统的支持,而带有包含一组实现定义特定语言支持库。
A conforming implementation may have extensions (including additional library functions), provided they do not alter the behavior of any well-formed program. Implementations are required to diagnose programs that use such extensions that are ill-formed according to this International Standard. Having done so, however, they can compile and execute such programs.
只要这些扩展不会改变任何良好形式程序的行为,符合标准的实现就可以带有扩展(包括附加的库功能)。实现应该将使用这些扩展的程序诊断成依据本国际标准为病态形式的。然而,这些程序可以被编译和执行。
3)“Correct execution” can include undefined behavior, depending on the data being procesed; see 1.3 and 1.9.
3) “正确执行”也可能产生未定义行为,这随被程序处理的数据而定。参见 1.3 和 1.9