没有合适的资源?快使用搜索试试~ 我知道了~
首页C++11新特性全英文电子书:现代C++开发指南
C++11新特性全英文电子书:现代C++开发指南
需积分: 5 1 下载量 89 浏览量
更新于2024-06-25
收藏 2.54MB PDF 举报
现代C++编程指南专为软件开发者而作,是Karan Singh Garewal的一本全英文教材,专注于介绍C++ 11的新特性和最佳实践。该书于2022年及以后版权保护,所有权利归Karan Singh Garewal所有。书中强调,尽管可能包含商标名称、标志和图像,但使用这些元素仅限于编辑性目的,以提升商标所有者利益,并无意侵犯其知识产权。
《Modern C++ for Software Developers》深入探讨了C++ 11的关键特性,如通用编程(Concepts)、范围基元(Range-based for loop)、智能指针(Smart Pointers)、Lambda表达式(Lambda Functions)以及右值引用(Rvalue References),这些都是C++语言在这一版本中的重大革新,旨在提高代码的效率和可读性。作者通过实例和实用案例,帮助读者理解和掌握这些新功能,使其在软件开发过程中能够充分利用C++ 11的优势。
此外,书中还涵盖了如何在严肃的项目开发中应用现代C++技术,包括如何处理并发编程(Concurrency)、异常处理(Exception Handling)以及模块化编程(Module System)。作者鼓励读者采用面向对象、泛型编程和模板等高级C++特性,以便在编写高效、可维护且易于扩展的代码时保持一致性。
在版权方面,这本书受版权法保护,禁止未经许可的翻译、复制、再版或任何形式的物质传播,包括微缩胶片、电子改编、计算机软件,以及任何尚未知或未来可能出现的类似方法。对于使用商标名、标志和形象,作者遵循版权规定,仅在必要时以非商业性质的方式提及,以尊重知识产权。
《Modern C++ for Software Developers》是一本适合希望深入学习C++ 11核心特性的专业开发者阅读的指南,它不仅提供了理论知识,还为实际项目中的实践应用提供了实用指导。通过跟随本书,读者可以了解到如何将这些新特性融入到日常编程中,从而提升开发效率和代码质量。
Overloading Function Templates......................................................................................................170
Using Ordinary Parameters With Function Templates......................................................................170
C++ Templates: Generic Classes.........................................................................................................172
An Example With Multiple Generic Data Types..........................................................................175
Using Non-Generic Arguments with class templates........................................................................176
Allowed Non-generic Template Parameters.................................................................................177
Using Default Arguments With Class Templates..............................................................................177
Explicit Class Specializations...........................................................................................................177
The typename Keyword....................................................................................................................179
C++ Exception Handling.....................................................................................................................180
Levels Of Exception Safety...............................................................................................................183
Catching Exception Class Types.......................................................................................................184
Standard Library Exceptions.............................................................................................................185
Using Multiple Catch Statements......................................................................................................185
Handling Derived-Class Exceptions.............................................................................................186
Catch All Exception Handler........................................................................................................187
Rethrowing An Exception.................................................................................................................187
Exceptions And Destructors..............................................................................................................189
terminate() and unexpected().............................................................................................................189
Setting Terminate and Unexpected Handlers................................................................................189
The uncaught_exception Function....................................................................................................191
C++ Run-time Type Identification......................................................................................................192
typeid And References..................................................................................................................195
Applying Typeid To Class Templates...........................................................................................197
C++ Type Cast Operators....................................................................................................................199
dynamic_cast.....................................................................................................................................199
Replacing dynamic_cast With typeid................................................................................................202
dynamic_cast And Different Derived Types.................................................................................203
dynamic_cast And References...........................................................................................................204
static_cast..........................................................................................................................................205
const_cast..........................................................................................................................................207
reinterpret_cast..................................................................................................................................208
C++ And Assembler.............................................................................................................................210
C++ Linkage Specification..................................................................................................................211
Summarizing the Differences Between C and C++...........................................................................213
C++ Standard Template Library........................................................................................................215
Containers.....................................................................................................................................215
Algorithms....................................................................................................................................215
Iterators.........................................................................................................................................215
Other STL Elements.....................................................................................................................216
The Container Classes.......................................................................................................................217
General Theory Of Operation.......................................................................................................218
Vector Containers..............................................................................................................................219
Accessing a Vector Through an Iterator.......................................................................................222
Understanding begin() And end().................................................................................................224
XV
Inserting and Deleting Elements in a Vector................................................................................224
Storing Class Objects in a Vector.................................................................................................226
List Containers..................................................................................................................................227
push_front vs push_back..............................................................................................................230
Storing Class Objects in a List......................................................................................................231
Maps (std::map).................................................................................................................................233
Inserting Elements Into A Map..........................................................................................................235
Getting A Map Key And A Key Value...............................................................................................236
A Map Container Example................................................................................................................236
Algorithms.........................................................................................................................................237
C++: Functors.......................................................................................................................................240
C++ Strings...........................................................................................................................................241
String Constructors............................................................................................................................241
String Operators................................................................................................................................241
String Concatenation.........................................................................................................................242
Convert A String Object To A C-Style String....................................................................................243
STL Algorithms For Strings..............................................................................................................244
Modern C++: Type_Traits (C++11)....................................................................................................245
Modern C++: Automatic Type Inference (C++11)............................................................................247
Modern C++: Type Deduction With decltype (C++11).....................................................................249
Type Attributes With auto And decltype.......................................................................................249
Modern C++: Trailing Return Types (C++11)...................................................................................251
Simplification Of Code.................................................................................................................252
Modern C++: Variable Initialization (C++11)...................................................................................253
Copy Assignment..............................................................................................................................253
Direct Initialization............................................................................................................................254
Brace Initialization............................................................................................................................254
The Meaning Of return {}.................................................................................................................255
std::initializer_list..............................................................................................................................256
Modern C++: explicit Keyword (C++11)...........................................................................................259
Modern C++: Range-Based For Loops (C++11)...............................................................................260
Modern C++: Lambda Functions (C++11)........................................................................................262
Lambda Specification........................................................................................................................263
Lambda Parameters...........................................................................................................................264
Access To Variables In The Outer Scope..........................................................................................265
Mutable Lambdas..............................................................................................................................267
The Type Of A Lambda................................................................................................................268
Generic Lambda Expressions............................................................................................................268
Generalized Lambda Introducer...................................................................................................269
Modern C++: Constexpr (C++11).......................................................................................................270
constexpr Functions...........................................................................................................................271
Restrictions On Constexpr Functions...........................................................................................272
Arrays And constexpr Functions.......................................................................................................272
Evaluating constexpr Objects at Compile-time.................................................................................273
Modern C++: lvalue And rvalue References (C++11)......................................................................275
XVI
Understanding lvalues and rvalues....................................................................................................275
Functions Returning lvalues And rvalues..........................................................................................276
lvalue References..........................................................................................................................277
Modern C++: Move Semantics (C++11)............................................................................................279
lvalues And rvalues...........................................................................................................................279
References.....................................................................................................................................280
Moving Objects.................................................................................................................................281
Moving A lvalue To A rvalue.............................................................................................................285
Throwing Exceptions........................................................................................................................286
Modern C++: Smart Pointers (C++11)..............................................................................................287
The Stack...........................................................................................................................................287
The Heap.......................................................................................................................................288
Types Of Memory Errors..................................................................................................................289
RAII...................................................................................................................................................291
The Smart Pointer Types...................................................................................................................293
std::unique_ptr...................................................................................................................................294
std::shared_ptr...................................................................................................................................299
Weak Pointers....................................................................................................................................302
Modern C++: Variadic Templates (C++11).......................................................................................305
Variadic Function Templates.............................................................................................................306
Parameter Pack Expansion................................................................................................................307
The sizeof… Operator.......................................................................................................................307
Modern C++: nullpointer (C++11).....................................................................................................309
Modern C++: Raw Strings (C++11)...................................................................................................311
Raw Strings.......................................................................................................................................311
Encoding String Literals....................................................................................................................312
Modern C++: noexcept Attribute (C++11)........................................................................................313
Modern C++: Override And Final (C++11).......................................................................................315
The override Attribute.......................................................................................................................315
Using override Can Prevent A Dangerous Bug............................................................................315
Override And Trailing Return Types............................................................................................316
Final Member Functions...................................................................................................................316
Final Member Classes.......................................................................................................................317
Modern C++: Constructor Delegation (C++11)................................................................................318
Modern C++: Static Assertions (C++11)............................................................................................321
Modern C++: Deleted And Default Functions (C++11)....................................................................323
default Keyword................................................................................................................................323
Deleted Functions And The Delete Keyword....................................................................................324
Modern C++: Typed Enums (C++ 11)................................................................................................326
C and C++ Enums.............................................................................................................................326
Typed Enums.....................................................................................................................................327
Data Types For An Enum..............................................................................................................328
Enum Type Safety.............................................................................................................................328
Forward References For Enums........................................................................................................329
Well-defined Enum Sizes: <cstdint>.................................................................................................329
XVII
Modern C++: Type Alias (C++11).......................................................................................................331
Typedef..............................................................................................................................................331
Type Alias Declarations With The using Keyword (using =)............................................................331
using And Templates.........................................................................................................................332
Modern C++: User Defined Literals (C++11)....................................................................................334
Restrictions On User Defined Types.................................................................................................335
Naming Rules For User Defined Literals..........................................................................................336
Modern C++: Template Constants (C++14)......................................................................................337
Modern C++: Return Type Deduction (C++14)................................................................................339
Return type deduction for functions..................................................................................................339
Modern C++: Generic Lambdas (C++14).........................................................................................340
Extended Capture In Lambdas..........................................................................................................340
Modern C++: Constexpr Template Constants (C++14)...................................................................343
Modern C++: Constexpr Functions (C++14)....................................................................................344
Modern C++: Digit Separator (C++14)..............................................................................................346
Modern C++: [[deprecated]] Attribute (C++14)...............................................................................347
Modern C++: Template Type Deduction (C++17)............................................................................348
Template Argument Type Deduction For Functions.........................................................................348
Template Type Deduction For Classes..............................................................................................349
Template Argument Deduction Guides.............................................................................................350
Modern C++: Non-Template Type Parameters (C++17)..................................................................351
Summary Of Non Template-Type Parameters...................................................................................351
Auto Non-Template Parameters........................................................................................................352
Modern C++: Nested Namespaces (C++17).......................................................................................353
Modern C++: Constexpr If Statements (C++17)...............................................................................354
Modern C++: Initialization Of Auto Types (C++17).........................................................................355
Modern C++: Structured Bindings (C++17).....................................................................................357
Using Structured Bindings................................................................................................................358
Structured Binding For Arrays.....................................................................................................359
Inheritance And Structured Bindings................................................................................................359
Modern C++: Initialization In If And Switch Statements (C++17).................................................360
Switch Statement With Initialization.................................................................................................361
Modern C++: Inline Variables (C++17).............................................................................................363
Using Inline Variables.......................................................................................................................364
Modern C++: Lambda Extensions (C++17)......................................................................................365
constexpr Lambdas............................................................................................................................365
Accessing The This Pointer In A Lambda.........................................................................................366
Modern C++: Type Includes The Exception Spec (C++17)..............................................................367
Modern C++: Empty Enum Initialization (C++17)..........................................................................369
Modern C++: Fold Expressions (C++17)...........................................................................................371
Using Fold Expressions.....................................................................................................................371
Handling Empty Parameter Packs.....................................................................................................372
Modern C++: string_view (C++17)....................................................................................................373
string_view And Scope......................................................................................................................374
A string_view Anti-Pattern...........................................................................................................376
XVIII
Modern C++: Initialization Of Aggregates (C++17).........................................................................377
Zero Initialization Of Aggregates.................................................................................................378
Modern C++: [[nodiscard]] Attribute (C++17).................................................................................380
Modern C++: [[maybe_unused]] Attribute (C++17)........................................................................382
Modern C++: __has_include Preprocessor Directive (C++17)........................................................383
Modern C++: The Spaceship Operator (C++20)..............................................................................384
Modern C++: consteval And constinit (C++20)................................................................................387
constinit Variables.............................................................................................................................388
constexpr try-catch Blocks................................................................................................................388
Modern C++: Initializers In Range-Based Loops (C++20)..............................................................391
Modern C++: Functions With auto Parameters (C++20)...............................................................392
Modern C++: Non-Parameter Types In Templates (C++20)...........................................................393
Modern C++: Virtual Constexpr Functions (C++20).......................................................................394
Modern C++: Concepts (C++20)........................................................................................................396
The Four Ways To Specify A Concept..............................................................................................397
The Requires Clause..........................................................................................................................398
Applying Concepts To The Return Type Of A Function...................................................................399
Using More Than One Concept.........................................................................................................399
Writing A Custom Concept...............................................................................................................399
Constrain auto With Concepts......................................................................................................402
Modern C++: Modules (C++20).........................................................................................................403
The Structure Of A Module File........................................................................................................404
Ways To Export Module Symbols.....................................................................................................405
Using Exported Module Symbols.....................................................................................................406
Module Interface Units And Module Implementation Units.............................................................406
Sub-modules......................................................................................................................................407
Module Partitions..............................................................................................................................408
A Note On Templates........................................................................................................................409
Linkage..............................................................................................................................................410
Header Units......................................................................................................................................410
Modern C++: Lambda Improvements (C++20)................................................................................411
Allow lambda-capture [=, this].....................................................................................................411
Modern C++: Designated Initialization (C++20)..............................................................................412
Modern C++: Using enum (C++20)....................................................................................................414
Modern C++: Conversion From ptr To bool (C++20)......................................................................415
Modern C++: boolalpha (C++20).......................................................................................................416
Modern C++: [[no_unique_address]] (C++20)..................................................................................417
Modern C++: [[likely]] and [[unlikely]] (C++20)..............................................................................418
Modern C++: Coroutines (C++20).....................................................................................................419
Introduction.......................................................................................................................................419
Why Is co_return Used Instead Of return?........................................................................................420
Coroutine Return Objects..................................................................................................................420
Instantiating A Coroutine...................................................................................................................422
Returning From A Coroutine.............................................................................................................423
Returning A Value From A Coroutine...............................................................................................424
XIX
剩余565页未读,继续阅读
2014-01-13 上传
2010-09-13 上传
2010-04-07 上传
2010-04-05 上传
2011-02-17 上传
2010-11-21 上传
2009-02-05 上传
我有个朋友是大曹村的
- 粉丝: 99
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 深入浅出:自定义 Grunt 任务的实践指南
- 网络物理突变工具的多点路径规划实现与分析
- multifeed: 实现多作者间的超核心共享与同步技术
- C++商品交易系统实习项目详细要求
- macOS系统Python模块whl包安装教程
- 掌握fullstackJS:构建React框架与快速开发应用
- React-Purify: 实现React组件纯净方法的工具介绍
- deck.js:构建现代HTML演示的JavaScript库
- nunn:现代C++17实现的机器学习库开源项目
- Python安装包 Acquisition-4.12-cp35-cp35m-win_amd64.whl.zip 使用说明
- Amaranthus-tuberculatus基因组分析脚本集
- Ubuntu 12.04下Realtek RTL8821AE驱动的向后移植指南
- 掌握Jest环境下的最新jsdom功能
- CAGI Toolkit:开源Asterisk PBX的AGI应用开发
- MyDropDemo: 体验QGraphicsView的拖放功能
- 远程FPGA平台上的Quartus II17.1 LCD色块闪烁现象解析
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功