Skip to Content
C++语言导学(原书第2版)
book

C++语言导学(原书第2版)

by 本贾尼 斯特劳斯特鲁普
August 2021
Intermediate to advanced
450 pages
5h 35m
Chinese
Pearson
Content preview from C++语言导学(原书第2版)

13.10 建议

[1] 对于库来说,不是大而复杂才会有用;13.1节。

[2] 所谓资源是指需要先申请后(显式或隐式)释放的东西;13.2节。

[3] 用资源句柄来管理资源(RAII);13.2节;[CG:R.1]。

[4] 用unique_ptr引用多态类型的对象;13.2.1节;[CG:R.20]。

[5] shared_ptr(仅)用于引用共享的对象;13.2.1节;[CG:R.20]。

[6] 与智能指针相比,优先选择具有特定语义的资源句柄;13.2.1节。

[7] 与shared_ptr相比,优先选择unique_ptr;5.3节、13.2.1节。

[8] 使用make_unique()构造unique_ptr;13.2.1节;[CG:R.22]。

[9] 使用make_shared()构造shared_ptr;13.2.1节;[CG:R.23]。

[10] 与垃圾回收机制相比,优先选择智能指针;5.3节,13.2.1节。

[11] 不要使用std::move();13.2.2节;[CG:ES.56]。

[12] 只使用std::forward()进行转发;13.2.2节。

[13] 在std::move()或std::forward()之后绝不从对象读取数据;13.2.2节。

[14] 与指针加计数的接口相比,优先选择span;13.3节;[CG:F.24]。

[15] 在需要序列的大小为constexpr的地方使用array;13.4.1节。

[16] 与内置数组相比,优先选择array;13.4.1节;[CG:SL.con.2]。

[17] 如果你需要使用N个二进制位,而N又并非恰好是某种内置整数类型的大小,则使用bitset;13.4.2节。

[18] 不要过度使用pair和tuple;命名struct通常会产生更易读的代码;13.4.3节。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

软件开发实践:项目驱动式的Java开发指南

软件开发实践:项目驱动式的Java开发指南

Raoul-Gabriel Urma, Richard Warburton
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey
Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu

Publisher Resources

ISBN: 9787111633280