C++11编程语言标准草案详解

需积分: 15 3 下载量 110 浏览量 更新于2024-07-19 收藏 10.11MB PDF 举报
“C++11标准,Working Draft,N3242=11-0012,2011年2月28日发布,由ISO/IEC制定,涵盖C++语言的各个方面,包括语法、内存模型、对象模型、程序执行、多线程等。” C++11是C++编程语言的一个重要版本,它引入了许多新特性、改进和优化,对现代软件开发有着深远的影响。以下是对C++11标准中一些关键知识点的详细解释: 1. **通用**:C++11标准旨在提供一个高效、灵活且可移植的编程环境,适用于各种应用程序,包括系统级编程、高性能计算以及大规模软件开发。 2. **范围**:C++11标准定义了C++语言的语法、语义和实现要求,旨在确保跨不同平台的一致性。 3. **规范引用**:标准引用了必要的其他规范,如ISO/IEC标准,这些规范共同构成了C++开发的基础。 4. **术语和定义**:标准明确了语言中的关键术语,如类型、表达式、声明、模板等,以便于理解和解析代码。 5. **实现合规**:标准提供了关于如何符合C++11标准的规定,允许编译器开发者和库作者实现兼容的C++环境。 6. **结构**:标准分为多个部分,包括基本概念、语法、程序结构、类型系统、内存模型等,帮助读者逐步理解语言的复杂性。 7. **C++内存模型**:这是C++11引入的重要更新之一,定义了并发程序中数据的访问和修改规则,确保了多线程环境下的正确性。 8. **C++对象模型**:描述了对象的生命周期、构造与销毁、继承和类型转换等,是理解类和对象行为的基础。 9. **程序执行**:这部分规定了程序的运行时行为,包括控制流、异常处理和程序终止。 10. **多线程执行与数据竞争**:C++11引入了内置的多线程支持,详细规定了线程间的交互,以及如何避免和处理数据竞争问题。 11. **感谢**:标准的这一部分通常用于感谢那些对标准制定做出贡献的人或组织。 12. **词法约定**:这部分涵盖了字符集、预处理、关键字、操作符、标识符等基本的词法规则,是编写C++代码的基础。 13. **分离翻译**:在编译过程中,源代码首先被分为独立的部分进行处理。 14. **预处理**:涉及宏定义、条件编译和包含头文件的过程。 15. **字符集**:C++11支持宽字符和Unicode,使得国际化和本地化更为方便。 16. ** trigraph sequences**:虽然不常用,但C++标准中仍然包含对三字符序列的处理。 17. **预处理标记**、**替代标记**和**令牌**:这些都是预处理阶段的产物,影响代码的解析和编译。 18. **注释**:C++支持单行和多行注释,用于添加非执行文本以解释代码。 19. **头文件名**:头文件的命名规则和包含机制是程序中引入库函数的关键。 20. **预处理数字**:指代预处理器如何处理数值常量。 21. **标识符**:定义了合法的变量、函数、类等名称的规则。 22. **关键字**:C++11增加了一些新的关键字,如`auto`、`nullptr`、`thread_local`等,扩展了语言功能。 23. **运算符和保留字**:标准列出了C++的所有运算符及其优先级,并定义了保留字的用途。 C++11标准的实施极大地提升了C++的现代性和实用性,包括但不限于lambda表达式、右值引用、自动类型推断、静态断言、类型别名、强类型枚举、智能指针等。这些特性让C++在保持其底层效率的同时,增加了可读性、安全性和易用性,成为了现代软件开发的首选语言之一。
2009-12-15 上传
该资源不适合C、C++初学者,可作为C++高手向大师级进化的参考书。 内容: ... 17 Library introduction 17.1 General 17.2 The C standard library 17.3 Definitions 17.4 Additional definitions 17.5 Method of description (Informative) 17.6 Library-wide requirements 18 Language support library 18.1 General 18.2 Types 18.3 Implementation properties 18.4 Integer types 18.5 Start and termination 18.6 Dynamic memory management CONTENTS v c ISO/IEC N3000=09-0190 18.7 Type identification 18.8 Exception handling 18.9 Initializer lists 18.10Other runtime support 19 Diagnostics library 456 19.1 General 19.2 Exception classes 19.3 Assertions 19.4 Error numbers 19.5 System error support 20 General utilities library 20.1 General 20.2 Requirements 20.3 Utility components 20.4 Compile-time rational arithmetic 20.5 Tuples 20.6 Metaprogramming and type traits 20.7 Function objects . 520 20.8 Memory 541 20.9 Time utilities 583 20.10Date and time functions 596 20.11Class type_index 596 21 Strings library 599 21.1 General 599 21.2 Character traits 599 21.3 String classes 605 21.4 Class template basic_string 608 21.5 Numeric Conversions 635 21.6 Null-terminated sequence utilities . 636 22 Localization library 640 22.1 General 640 22.2 Header <locale> synopsis 640 22.3 Locales 641 22.4 Standard locale categories . 653 22.5 Standard code conversion facets 693 22.6 C Library Locales 695 23 Containers library 696 23.1 General 696 23.2 Container requirements 696 23.3 Sequence containers 719 23.4 Associative containers . 758 23.5 Unordered associative containers . 776 24 Iterators library 791 24.1 General 791 24.2 Iterator requirements 791 CONTENTS vi c ISO/IEC N3000=09-0190 24.3 Header <iterator> synopsis 796 24.4 Iterator primitives 799 24.5 Iterator adaptors . 802 24.6 Stream iterators . 816 25 Algorithms library 825 25.1 General 825 25.2 Non-modifying sequence operations 835 25.3 Mutating sequence operations 839 25.4 Sorting and related operations 848 25.5 C library algorithms 862 26 Numerics library 864 26.1 General 864 26.2 Numeric type requirements . 864 26.3 The floating-point environment 865 26.4 Complex numbers 866 26.5 Random number generation . 876 26.6 Numeric arrays 920 26.7 Generalized numeric operations 940 26.8 C Library 944 27 Input/output library 949 27.1 General 949 27.2 Iostreams requirements . 950 27.3 Forward declarations 950 27.4 Standard iostream objects 952 27.5 Iostreams base classes . 954 27.6 Stream buffers 972 27.7 Formatting and manipulators 982 27.8 String-based streams 1009 27.9 File-based streams 1021 28 Regular expressions library 1036 28.1 General 1036 28.2 Definitions 1036 28.3 Requirements 1037 28.4 Header <regex> synopsis 1039 28.5 Namespace std::regex_constants 1045 28.6 Class regex_error 1048 28.7 Class template regex_traits 1048 28.8 Class template basic_regex 1051 28.9 Class template sub_match 1056 28.10Class template match_results 1062 28.11Regular expression algorithms 1066 28.12Regular expression Iterators . 1070 28.13Modified ECMAScript regular expression grammar 1076 29 Atomic operations library 1079 29.1 General 1079 29.2 Header <atomic> synopsis 1079 CONTENTS vii c ISO/IEC N3000=09-0190 29.3 Order and Consistency . 1082 29.4 Lock-free Property 1084 29.5 Atomic Types 1085 29.6 Operations on Atomic Types 1094 29.7 Flag Type and Operations 1098 29.8 Fences . 1099 30 Thread support library 1101 30.1 General 1101 30.2 Requirements 1101 30.3 Threads 1102 30.4 Mutual exclusion . 1107 30.5 Condition variables 1121 30.6 Futures 1129 A Grammar summary 1149 A.1 Keywords 1149 A.2 Lexical conventions 1149 A.3 Basic concepts 1154 A.4 Expressions . 1154 A.5 Statements . 1158 A.6 Declarations . 1159 A.7 Declarators . 1162 A.8 Classes . 1164 A.9 Derived classes 1165 A.10 Special member functions 1165 A.11 Overloading . 1165 A.12 Templates 1166 A.13 Exception handling 1167 A.14 Preprocessing directives 1167 B Implementation quantities 1169 C Compatibility 1171 C.1 C++ and ISO C 1171 C.2 Standard C library 1181 D Compatibility features 1185 D.1 Increment operator with bool operand . 1185 D.2 static keyword . 1185 D.3 Access declarations 1185 D.4 Implicit conversion from const strings . 1185 D.5 register keyword 1185 D.6 C standard library headers . 1185 D.7 Old iostreams members 1186 D.8 char* streams 1187 D.9 Binders 1196 D.10 auto_ptr 1198 E Cross references 1201 Index 1218 CONTENTS viii ISO/IEC N3000=09-0190 Index of Grammar Productions 1243 Index of Library Names 1246 Index of Implementation Defined Behavior 1280