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++(中文版)
68
3
C++11
之所以要这么做,有其历史原因,不过我这里不打算展开(那是一篇枯燥的长
篇大论),反正由于标准委员会对于别名模板的好处后知后觉,所以他们到了
C++14
中才为
C++11
中的所有型别变换都加上了对应的别名模板。这些别名有一个公共形
式:每个
C++11
中的变换
std::transformation<T>::type
,都有一个
C++14
中名为
std::transformation
_t
的对应别名模板。下面的例子能够清楚说明我想表达的意思:
std::remove_const<T>::type
// C++11
const T
T
std::remove_const
_t
<T>
// C++14
中的等价物
std::remove_reference<T>::type
// C++11: T&/T&&
T
std::remove_reference
_t
<T>
// C++14
中的等价物
std::add_lvalue_reference<T>::type
// C++11: T
T&
std::add_lvalue_reference
_t
<T>
// C++14
中的等价物
C++11
的基础设施在
C++14
中仍然可用,但我不知道为什么你还会用它们。即使你
还没用上
C++14
,自行写出这些别名声明也是连小孩子都会的功夫。要用的只涉及
C++11
的语言特性,而且连小孩子也会照葫芦画瓢对吧?如果你有
C++14
标准的电
子版,那就更简单,只需要复制粘贴就可以了。我在这里把你扶上马送一程吧: ...
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

C++程序设计:原理与实践(基础篇)(原书第2版)

C++程序设计:原理与实践(基础篇)(原书第2版)

本贾尼 斯特劳斯特鲁普
C++语言导学(原书第2版)

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

本贾尼 斯特劳斯特鲁普
Go语言编程

Go语言编程

威廉·肯尼迪

Publisher Resources

ISBN: 9787519817749