Preface

If you are holding this book in the store,you might be wondering why you should read this book among many C++books.First,you should know this book is about the latest new C++11(codenamed C++0x)Standard ratified at the end of 2011.This new Standard is almost like a new language,with many new language and library features but there is a strong emphasis for compatibility with the last C++98/03 Standard during design.At the time of printing of this book in 2013,this is one of the first few C++11 books published.All books that do not mention C++11 will invariably be talking about C++98/03.

What makes this book different is that it is written by Chinese writers,in its original Chinese language.In fact,all of us are on the C++compiler team for the IBM xlC++compiler,which has been adding C++11 features since 2008.

For my part,I am the C++Standard representative for IBM and Canada and have been working in compilers for 20 years,and is the author of several C++11 features while leading the IBM C++Compiler team.

For C++users who read Chinese,many prefer to read an original Chinese language book,rather than a translated book,even if they can read other languages.While very well written also by experts from the C++Standard Committee,these non-Chinese books'translation can take time,or result in words or meanings that are loss in translation.The translator has a tough job as technical books contain many jargon and new words that may not have an exact meaning in Chinese.Different translators may not use the same word,even within the same book.These are reasons that lead to a slow dissemination of C++knowledge and slows the adoption of C++11 in Chinese.

These are all reasons that lead to weak competitiveness.We aim to improve that competiveness with a book written by Chinese-speaking writers,with a uniform language for jargons,who understand the technology gap as many of the writers work in the IBM Lab in Shanghai.We know there are many Chinese-speaking C++enthusiasts who are eager to learn and use the updates to their favorite language.The newness of C++11 also demands a strong candidate in the beginner to intermediate level of C++11,which is the level of this book.

You should do well reading this book,if you are:

❑an experienced C programmer who wants to see what C++11 can do for you.

❑already a C++98/03 programmer who wants to learn the new C++11 language.

❑anyone interested in learning the new C++11 language.

We structure this book using the design principles that Professor Bjarne Stroustrup,the father of C++followed in designing C++11 through the Standard Committee.In fact,we separated this book into chapters based on those design principles.These design principles are outlined in the first chapter.The remaining chapters separate every C++11 language features under those design classifications.For each feature,it will explain the motivation for the feature,the rules,and how it is used,taking from the approved C++11 papers that proposed these features.A further set of appendices will outline the current state of the art of compiler support for C++11,incompatibilities,deprecated features,and links to the approved papers.

After reading this book,you should be able to answer questions such as:

❑What is a lambda and the best way to use it?

❑How is decltype and auto type inference related?

❑What is move semantics and how does it solve the forwarding problem?

❑I want to understand default and deleted as well as explicit overrides.

❑What did they replace exception specifications with and how does noexcept work?

❑What are atomics and the new memory model?

❑How do you do parallel programming in C++11?

What we do not cover are the C++11 changes to the Standard library.This part could be a book itself and we may continue with this as Book II.This means we will not talk about the new algorithms,or new class libraries,but we will talk about atomics since most compilers implement atomics as a language feature rather than a library feature for efficiency reason.However,in the C++11 Standard,atomics is listed as a library feature simply because it could be implemented at worst as a library,but very few compilers would do that.This book is also not trying to teach you C++.For that,we particularly recommend Professor Stroustrup's book Programming principles&Practice Using C++which is based on an excellent course he taught at Texas A&M University on programming.

This book could be read chapter by chapter if you are interested in every feature of C++11.More likely,you would want to learn about certain C++11 feature and want to target that feature.But while reading about that feature,you might explore other features that fall under the same design guideline.

We hope you find this book useful in your professional or personal learning.We learnt too during our journey of collaborating in writing this book,as we wrote while building the IBM C++compiler and making it C++11 compliant.

The work of writing a book is long but it is well worth it.While I have been thinking about writing this book while working on the C++Standard,it was really Xiao Feng Guan who motivated me to start really stop thinking and start doing it for real.He continued to motivate and lead others through their writing assignment process and completed the majority of the work of organizingthis book.I also wish to thank many who have been my mentors officially and unofficially.There are too many to mention but people such as Bjarne Stroustrup,Herb Sutter,Hans Boehm,Anthony Williams,Scott Meyers and many others have been my teachers and great examples of leaders since I started reading their books and watching how they work within large groups.IBM has generously provided the platform,the time,and the facility to allow all of us to exceed ourselves,if only just a little to help the next generation of programmers.Thank you above all to my family Sophie,Cameron,Spot the Cat,and Susan for lending my off-time to work on this book.

Michael