Standard C++ (original) (raw)

C++11 Overview

C++11: Purpose of this FAQ section

The purpose of this FAQ’s C++11 sections (including this section) is:

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, noexcept, and 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

The overall aims of the C++11 effort was to strengthen that:

For more details see:

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:

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:

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

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).

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:

Are there any videos about C++11?

Yes:

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:

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.