C++11: Purpose of this FAQ section
The purpose of this FAQ’s C++11 sections (including this section) is:
- To give an overview of the new facilities (language features and standard libraries) offered by C++11 in addition to what is provided by the previous version of the ISO C++ standard.
- To give an idea of the aims of the ISO C++ standards effort.
- To present a user’s view of the new facilities
- To provide references to allow for a more in depth study of features.
- To name many of the individuals who contributed (mostly as authors of the reports they wrote for the committee). The standard is not written by a faceless organization.
We often borrow examples from the proposals. In those cases: Thanks to the proposal authors. Many other examples are borrowed from Stroustrup’s talks and papers.
Please note that the purpose of this FAQ is not to provide comprehensive discussion of individual features or a detailed explanation of how to use them. The aim is to give simple examples to demonstrate what C++11 has to offer (plus references). Our ideal is “max one page per feature” independently of how complex a feature is. Details can often be found in the references.
See the FAQ Home page for a list of all C++11 sections.
What is C++11?
C++11 is the ISO C++ standard formally ratified by a 21-0 national vote in August 2011. This public working paper is the January 2012 working draft, and contains the C++11 standard plus minor editorial changes.
C++11 is a major upgrade over C++98/03, with performance and convenience features that make it feel like a new language.
The previous (and first) standard is often referred to as C++98 or C++03; the differences between C++98 and C++03 are so few and so technical that they ought not concern users. This FAQ discusses changes between C++98/C++03 to C++11.
What is C++0x?
The “under-development” name for C++11. Before its official ratification in 2011, the then-under-development standard was unofficially called C++0x, as it was hoped to be completed in C++08 or C++09. Think of ‘
x’ as hexadecimal (i.e., C++
0B == C++11).
When will compilers implement C++11?
Currently shipping compilers (e.g. GCC C++, Clang C++, IBM C++, and Microsoft C++) already implement most or all C++11 features, and are working on C++14 features.
Modulo bugs, the first fully conforming C++11 language implementation was GCC 4.8.1 (May 31, 2013) but it still did not have a conforming standard library. The first complete C++11 implementation, including both the language and the standard library, was Clang 3.3 (June 5, 2013).
Here are links to C++11 information from purveyors:
How did the committee approach picking new language and library features for C++11?
You don’t improve a language by simply adding every feature that someone considers a good idea. In fact, essentially every feature of most modern languages has been suggested for C++ by someone: Try to imagine what the union of C99, C#, Java, Haskell, Lisp, Python, and Ada would look like. To make the problem more difficult, remember that it is not feasible to eliminate older features, even in the reasonably rare cases when the committee agrees that they are bad: Experience shows that users force every implementer to keep providing deprecated and banned features under compatibility switches (or by default) for decades.
In addition to the general design goals, to try to select rationally from the flood of suggestions the committee devised a set of specific design goals. The result has been a language with greatly improved abstraction mechanisms. The range of abstractions that C++ can express elegantly, flexibly, and at zero cost compared to hand-crafted specialized code has greatly increased. When we say “abstraction” people often just think “classes” or “objects.” C++11 goes far beyond that: The range of user-defined types that can be cleanly and safely expressed has grown with the addition of features such as initializer-lists, uniform initialization, template aliases, rvalue references, defaulted and deleted functions, and variadic templates. Their implementation eased with features, such as auto, inherited constructors, and decltype. These enhancements are sufficient to make C++11 feel like a new language.
For information about accepted language features, see the C++11 language extensions sections of this FAQ, listed on the FAQ Home page.
The standard library definition is already about 70% of the normative text of the standard (and that doesn’t count the C standard library, which is included by reference). Even though some members would have liked to see many more standard libraries, nobody could claim that the Library Working Group has been lazy. It is also worth noting that the C++98 libraries have been significantly improved through the use of new language features, such as initializer-lists, rvalue references, variadic templates,
constexpr. The C++11 standard library is easier to use and provides better performance than the C++98 one.
For information about accepted library features, see the C++11 library extensions sections of this FAQ, listed on the FAQ Home page.
What were the general design goals of the C++11 effort?
C++ has from its inception been a general-purpose programming language with a bias towards systems programming that
- is a better C
- supports data abstraction
- supports object-oriented programming
- supports generic programming
The overall aims of the C++11 effort was to strengthen that:
- Make C++ a better language for systems programming and library building – that is, to build directly on C++’s contributions to programming, rather than providing specialized facilities for a particular sub-community (e.g. numeric computation or Windows-style application development).
- Make C++ easier to teach and learn – through increased uniformity, stronger guarantees, and facilities supportive of novices (there will always be more novices than experts).
- Naturally, this is done under very stringent compatibility constraints. Only very rarely is the committee willing to break standards conforming code, though that’s done when a new keyword (e.g.
constexpr) is introduced.
For more details see:
- B. Stroustrup: What is C++11?. CVu. Vol 21, Issues 4 and 5. 2009.
- B. Stroustrup: Evolving a language in and for the real world: C++ 1991-2006. ACM HOPL-III. June 2007.
- B. Stroustrup: A History of C++: 1979-1991. Proc ACM History of Programming Languages conference (HOPL-2). March 1993.
- B. Stroustrup: C and C++: Siblings. The C/C++ Users Journal. July 2002.
What specific design goals guided the committee?
Naturally, different people and different organizations involved with the standardization have somewhat different aims, especially when it comes to details and to priorities. Also, detailed aims change over time. Please remember that the committee can’t even do all that everyone agrees would be good things – it consists of volunteers with very limited resources. However, here are a set of criteria that has seen real use in the discussion of which features and libraries were appropriate for C++11:
- Maintain stability and compatibility – don’t break old code, and if you absolutely must, don’t break it quietly.
- Prefer libraries to language extensions – an ideal at which the committee wasn’t all that successful; too many people in the committee and elsewhere prefer “real language features.”
- Prefer generality to specialization – focus on improving the abstraction mechanisms (classes, templates, etc.).
- Support both experts and novices – novices can be helped by better libraries and through more general rules; experts need general and efficient features.
- Increase type safety – primarily though facilities that allow programmers to avoid type-unsafe features.
- Improve performance and ability to work directly with hardware – make C++ even better for embedded systems programming and high-performance computation.
- Fit into the real world – consider tool chains, implementation cost, transition problems, ABI issues, teaching and learning, etc.
Note that integrating features (new and old) to work in combination is the key – and most of the work. The whole is much more than the simple sum of its parts.
Another way of looking at detailed aims is to look at areas of use and styles of usage:
- Machine model and concurrency – provide stronger guarantees for and better facilities for using modern hardware (e.g. multicores and weakly coherent memory models). Examples are threads, futures, thread-local storage, and atomics.
- Generic programming – GP is among the great success stories of C++98; we needed to improve support for it based on experience. Examples are auto and template aliases.
- Systems programming – improve the support for close-to-the-hardware programming (e.g. low-level embedded systems programming) and efficiency. Examples are
std::array, and generalized PODs.
- Library building – remove limitations, inefficiencies, and irregularities from the abstraction mechanisms. Examples are
inline namespace, inherited constructors, and rvalue references.
Where can I find the committee papers for C++11 features?
Go to the committee papers archive and focus mainly on 2005 through early 2011. There you will most likely drown in details. Look for “issues lists” and “State of” (e.g. State of Evolution (July 2008)) lists. The key groups then active were
- Core (CWG) – dealing with language-technical issues and formulation
- Evolution (EWG) – dealing with language feature proposals and issues crossing the language/library boundary
- Library (LWG) – dealing with library facility proposals
Where can I find academic and technical papers about C++11?
Here is an incomplete list. To suggest additions or corrections, use the Suggestion icon on this FAQ heading (you can do that on any FAQ of course).
- Bjarne Stroustrup: Software Development for Infrastructure. Computer, vol. 45, no. 1, pp. 47-58, Jan. 2012, doi:10.1109/MC.2011.353. Here is a video interview about that paper and video of a talk on a very similar topic (That’s a 90 minute talk incl. Q&A).
- Saeed Amrollahi: Modern Programming in the New Millenium: A Technical Survey on Outstanding features of C++0x. Computer Report (Gozaresh-e Computer), No.199, November 2011 (Mehr and Aban 1390), pages 60-82. (in Persian)
- Mark Batty et al’s: Mathematizing C++ concurrency, POPL 2012. // thorough, precise, and mathematical.
- Gabriel Dos Reis and Bjarne Stroustrup: General Constant Expressions for System Programming Languages. SAC-2010. The 25th ACM Symposium On Applied Computing.
- Hans-J. Boehm and Sarita V. Adve: Foundations of the C++ concurrency memory model. ACM PLDI’08.
- Hans-J. Boehm: Threads Basic. HPL technical report 2009-259 // “what every programmer should know about memory model issues”
- Douglas Gregor, Jaakko Jarvi, Jeremy Siek, Bjarne Stroustrup, Gabriel Dos Reis, and Andrew Lumsdaine: Concepts: Linguistic Support for Generic Programming in C++. OOPSLA’06, October 2006. // The concept design and implementation as it stood in 2006; it has improved since, though not sufficiently to save it for C++11, and is now being worked on for a future C++ standard.
- Douglas Gregor and Jaakko Jarvi: Variadic templates for C++0x. Journal of Object Technology, 7(2):31-51, February 2008.
- Jaakko Jarvi and John Freeman: Lambda functions for C++0x. ACM SAC ‘08.
- M. Paterno and W. E. Brown: Improving Standard C++ for the Physics Community. CHEP’04. // Much has been improved since then!
- Michael Spertus and Hans J. Boehm: The Status of Garbage Collection in C++0X. ACM ISMM’09.
- Verity Stob: An unthinking programmer’s guide to the new C++ – Raising the standard. The Register. May 2009. (Humor (I hope)).
- [N1781=05-0041] Bjarne Stroustrup: Rules of thumb for the design of C++0x.
- Bjarne Stroustrup: Evolving a language in and for the real world: C++ 1991-2006. ACM HOPL-III. June 2007. (incl. slides and videos). // Covers the design aims of C++0x, the standards process, and the progress up until 2007.
- B. Stroustrup: What is C++0x?. CVu. Vol 21, Issues 4 and 5. 2009.
- Anthony Williams: Simpler Multithreading in C++0x. devx.com.
Where else can I read about C++11?
The amount of information about C++11 is increasing as most C++ implementations provide the new language features and libraries. Here is a short list of sources:
- B. Stroustrup: The C++ Programming Language (Fourth Edition).
- B. Stroustrup: A Tour of C++.
- The committe papers archive.
- The C++11 standard (closest public approximation)
- The C++11 Wikipedia entry. This seems to be actively maintained, though apparently not by members of the committee.
- A list of support for C++11 features.
Are there any videos about C++11?
- B. Stroustrup, H. Sutter, H-J. Boehm, A. Alexandrescu, S.T.Lavavej, Chandler Carruth, and Andrew Sutton: Several talks and panels from the GoingNative 2012 conference.
- B. Stroustrup, H. Sutter, S. Meyers, A. Alexandrescu, S.T.Lavavej, Chandler Carruth, S. Parent, and M. Wong: Several talks and panels from the GoingNative 2013 conference.
- Herb Sutter: Writing Modern C++ Code: How C++ has evolved over the years. September 2011.
- Herb Sutter: Why C++?. C++ and Beyond 2011, August 2011.
- Herb Sutter: (Not Your Father’s) C++. Lang.NEXT, April 2012.
- Herb Sutter: atomic<> Weapons: The C++ Memory Model and Modern Hardware, Part 1, Part 2, Slides, from C++ and Beyond, August 2012.
- Lawrence Crowl: Lawrence Crowl on C++ Threads. in Sophia Antipolis, June 2008.
- Bjarne Stroustrup: The design of C++0x. University of Waterloo, 2007.
- Bjarne Stroustrup: Initialization. Google, 2007.
- Bjarne Stroustrup: C++0x – An overview. in Sophia Antipolis, June 2008.
- Lawrence Crowl: Threads.
- Roger Orr: C++0x. January 2008.
- Hans-J. Boehm: Getting C++ Threads Right. December 2007.
Is C++11 hard to learn?
C++11 makes C++ easier to learn than ever, and has near-perfect compatibility with C++98/03.
For those who have never used C++, C++11 is far easier to learn than the previous version of the language. Even though there are more features, the code you write tends to be simpler and many things that used to be hard or obscure aren’t any more. (Of course, like any general-purpose language, there are still some hard or obscure parts.) In fact, Stroustrup now covers the essentials of the entire C++11 language and library in one concise 180-page book, A Tour of C++.
If you know C++98/03, essentially all your code will continue to work unchanged because C++11 is nearly perfectly backward-compatible with the previous standard. However, as you learn the new features, you will find that they often make your code simpler (e.g.,
auto), clearer (e.g., template aliases instead of
typedef), more powerful and expressive (e.g., lambda functions), and faster than ever (e.g., rvalue references and move semantics will often make your existing C++ code faster simply by recompiling it with a C++11 compiler!). The extra simplicity and clarity really make C++11 feel like a fresh new language.
Clearly C++11 is bigger than C++98 and has more features. So how can it be easier to learn? When designing C++11, the committee used several tools for simplification (from the point of view of learners), including:
- Generalization: In some cases C++11 replaces, say, three rules with one more general rule (e.g., uniform initialization, inheriting constructors, and threads). It also removes special cases so there’s less to learn (as a trivial example,
vector<vector<int>>is perfectly legal now without putting a space between
>>). All of this reduces “concept count” or the number of things to memorize by rote; for example, a rule with three exceptions or special cases has a concept count of four things to memorize, whereas two general rules that just work together in all combinations have a concept count of just two things to memorize, yet can often express much more than the single rule with three special cases.
- Simpler alternatives: In other cases C++11 provides new facilities that are easier to use than their older alternatives (e.g.,
std::array, auto, range-for statement, and regex).
A word of caution: People who insist on teaching C++ “from the bottom up” (corner cases first, C subset first, etc.) will nullify any such advantage and make the language appear obscure and hard. This is not necessary or desirable. We are finally getting better materials that teach C++ from the top down, notably Stroustrup’s A Tour of C++. If you see people learning C++ from the bottom up, steer them to the Tour and similar materials as quickly as possible.
Is C++11 the final C++ standard?
No. The upcoming next C++ International Standard is called C++14 as it is expected to be published in 2014, and as of this writing it is nearly finalized. The committee is also working on issuing numerous Technical Specifications due in 2014 onward, on topics from low-level libraries like File System and Networking to Concurrency and Parallelism and Concepts, and more. Many of these Technical Specifications are expected to become part of the next major actual C++ International Standard, currently expected in about 2017.
For the latest details, see the current status page.