C++11 and the guardians of tradition

C++11 (formerly C++ 0x) the new ISO standard of the C++ language is extended, said Bjarne Stroustrup, its creator, according to three levels:

C++ prefers feat rather than simplicity

  1. Language.
  2. Standard library.
  3. Concurrency.

The definition of the standard has been approved by the ISO C++ comittee on March 25, 2011.

The semantics essentially will be improved, mainly types and security provided by controls on the types, but new control structures will appear.
The internal UTF-8 format is now supported for strings.

New types and keywords

  1. auto
    Type of variable deduced from what is assigned. Example:
    vector <string> v = ( "Alicia", "Bea", "Clara", "Dara"); 
    for (auto x: v) cout "x" '\ n';
  2. constexpr
    A constant expression.
  3. nullptr
    A reserved word for a null pointer.
    char *x = nullptr;
  4. raw string
    String where escape codes are not interpreted, as in PHP with single quotes.
    They have the R prefix.
  5. decltype
    How to use the type of an expression, returns the type and modifiers of any object including a function.
  6. UTF 8 string literal
    u8"Some text".
    u is used for UTF 16 and U for UTF 32.

Security on types

  1. Control of alignment of values.
  2. Control of default values.

New constructs

For loop over an interval.
As it is implemented on most scripting languages.

int arr[5] = {2, 8, 21, 56, 995}; 
for (int &x : arr) 
  printf("%d\n", x);  

As you can see, the language retains the principle of minimal source code. It does not use the keyword in as do  most languages​​, but a symbol instead.
A tradition that was born when it was necessary to save each character to reduce the size of code! Memory was expensive in 1972 ...

Lambda function.
Functions defined in place for a contextual use.

This is a reference to the contents of a variable, where the A variable is assigned the content of B without a copy but by moving the pointer on the new content, in the perspective where B is no longer used.

Variadic template.
Template whose number of arguments is variable.

Static assertion.
Introduced with the keyword static_assert, it tests the validity of an assertion at compile-time.

Typed enum with scope.


Delegating and inheriting constructors. The constructor of a class can call constructors of other classes.

Attributes of classes may be assigned directly in the definition of the class.

Standard library

New object appear that already became familiar in scripting languages such as PHP.

  1. regexp
    Regular Expressions.
  2. tuple
    Used in the Python language.
  3. Array
    Static array.
  4. unordered_map
    Hash table.
  5. Date.
  6. Smart pointer.

And many various components of libraries and improvements. For example, now you can assign a static list to a vector at its declaration.


Multiple threads with shared memory are easy to use. To make it, we create a function and call it through a function pointer in the thread command ...

#include <thread>

void f(int a)
  ... code...

int main() {
  thread t(&f, 1000);

The join() command starts the thread.

he async command calls a function asynchronously, something that has become familiar with Ajax.

Features for concurrency in C++11:

  1. Memory model adapted to today's computers with multi-core processors.
  2. Threading ABI.
  3. Atomic types.
  4. Mutexes and locks.
  5. Thread local storage.
  6. Exchanging messages asynchronously.

What is missing (for a modern language)

A garbage collector.
An automatic memory manager. It will be optional, some applications do not need and do not use it.

Modules (in the sense of Python where the semantics of language can be extended when it incorporates a library).

Dynamic arrays or bound control.
It has already an equivalent in the current library with the vector class.

One way to define abstract arguments to templates.


In version 2011 the C++ language will gets many facilities inherited from other programming languages and from Java, but it remains complex, and even more complex with the development of generic templates and remains a language dedicated to system development.
To quote the creator himself, "the ugly and illogical C syntax" is still the best way to make system programming (compilers, operating systems, drivers, etc.).

But thirty years later (C++ was created in 1981), we could have imagined some progress to simplify its use, even in this domain. However, it still has no successor for system programming.