Skip to Content
Effective Modern C++(中文版)
book

Effective Modern C++(中文版)

by Scott Meyers
April 2018
Intermediate to advanced
303 pages
4h 54m
Chinese
China Electric Power Press Ltd.
Content preview from Effective Modern C++(中文版)
12
绪论
我把函数声明的形参型别和返回值型别这部分定义为函数的签名,而函数名字和形
参名字则不属于签名的组成部分。在上例中,
func
的签名是
bool(const Widget&)
函数声明除形参型别和返回值型别的其他组成元素(即可能存在的
noexcept
constexpr
)则被排除在外(
noexcept
constexpr
的内容详见条款
14
条款
15
。“
名”的官方定义与我给出的稍有不同,但在本书中,我的定义更加实用(官方定义有
时会省去返回值型别)。
通常来说,在
C++
旧标准下写就的代码在
C++
新标准下仍然会保有合法性,但有时
标准化委员会也会废弃某些特性。这些特性在标准化的前途上已是穷途末路,并有可
能在未来的标准中被去除。编译器可能会,也可能不会对于在代码中使用这些已废
弃特性的行为给出警告,但是你应该尽力避免使用它们。它们不仅会造成未来的可
移植性问题,而且还不如那些替换掉它们的新特性好用。例如,在
C++11
标准中,
std::auto_ptr
就是个被废弃的特性,因为
std::unique_ptr
可以完成同样的任务,
并且使用起来更方便。
标准有时会把某个操作的结果说成是未定义行为。意思是,其运行期行为不可预测,
你当然会对这样的不确定性敬而远之。未定义行为的例子有,在方括号(“
[]
”)内
使用越界值作为
std::vector
的下标,对未初始化的迭代器实施提领操作,或者进入
数据竞险(即两个或更多线程同时访问同一内存位置,且其中至少有一个执行写操作
的情形)。
我将内建的指针,就是
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

流畅的Python(第2版)

流畅的Python(第2版)

Luciano Ramalho
Go语言编程

Go语言编程

威廉·肯尼迪

Publisher Resources

ISBN: 9787519817749