C++11
C++11 is the second major version of C++ and the most important update since C++98. A large number of changes were introduced to both standardize existing practices and improve the abstractions available to the C++ programmers.
Before it was finally approved by ISO on 12 August 2011, the name 'C++0x' was used because it was expected to be published before 2010. It took 8 years between C++03 and C++11, so it has become the longest interval between versions so far. Since then, currently, C++ updates every 3 years regularly.
| This section is incomplete |
Following features were merged into C++11:
- From TR1 : all of TR1 except Special Functions .
- From Boost: The thread library , exception_ptr , error_code and error_condition , iterator improvements ( begin , end , next , prev )
- From C: C-style Unicode conversion functions
Contents |
Core language features
- auto and decltype
- defaulted and deleted functions
- final and override
- trailing return type
- rvalue references
- move constructors and move assignment operators
- scoped enums
- constexpr and literal types
- list initialization
- delegating and inherited constructors
- brace-or-equal initializers
- nullptr
- long long
- char16_t and char32_t
- type aliases
- variadic templates
- generalized (non-trivial) unions
- generalized PODs ( trivial types and standard-layout types )
- Unicode string literals
- user-defined literals
- attributes
- lambda expressions
- noexcept specifier and noexcept operator
- alignof and alignas
- multithreaded memory model
- thread-local storage
- GC interface (removed in C++23)
- range- for (based on Boost library)
- static_assert (based on Boost library)
| This section is incomplete |
Library features
Headers
- <array>
- <atomic>
- <cfenv>
- <chrono>
- <cinttypes>
- <condition_variable>
- <cstdint>
- <cuchar>
- <forward_list>
- <future>
- <initializer_list>
- <mutex>
- <random>
- <ratio>
- <regex>
- <scoped_allocator>
- <system_error>
- <thread>
- <tuple>
- <typeindex>
- <type_traits>
- <unordered_map>
- <unordered_set>
Library features
- concurrency support library
-
emplace()and other use of rvalue references throughout all parts of the existing library - std::unique_ptr
- std::move_iterator
- std::initializer_list
- stateful and scoped allocators
- std::forward_list
- chrono library
- ratio library
- new algorithms :
-
- std::all_of , std::any_of , std::none_of ,
- std::find_if_not ,
- std::copy_if , std::copy_n ,
- std::move , std::move_backward ,
- std::random_shuffle , std::shuffle ,
- std::is_partitioned , std::partition_copy , std::partition_point ,
- std::is_sorted , std::is_sorted_until ,
- std::is_heap , std::is_heap_until ,
- std::minmax , std::minmax_element ,
- std::is_permutation ,
- std::iota ,
- std::uninitialized_copy_n
- Unicode conversion facets
- std::function
- std::exception_ptr
- std::error_code and std::error_condition
- iterator improvements:
| This section is incomplete |
Defect reports
Compiler support
C++11 core language features
|
C++11 feature
|
Paper(s)
|
GCC
|
Clang
|
MSVC
|
Apple Clang
|
EDG eccp
|
Intel C++
|
Nvidia HPC C++ (ex PGI)*
|
Nvidia nvcc
|
Cray
|
Embarcadero C++ Builder
|
IBM Open XL C++ for AIX
|
IBM Open XL C++ for z/OS
|
IBM XL C++
|
Sun/Oracle C++
|
HP aCC
|
Digital Mars C++
|
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| C99 preprocessor | N1653 | 4.3 | Yes |
19.0 (2015)*
(partial)*
19.26* |
Yes | 4.1 | 11.1 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 10.1 | 5.9 | A.06.25 | Yes | |
| static_assert ( FTM ) * | N1720 | 4.3 | 2.9 | 16.0* | Yes | 4.1 | 11.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.25 | 8.52 | |
| Right angle brackets | N1757 | 4.3 | Yes | 14.0* | Yes | 4.1 | 11.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 12.1 | 5.13 | |||
| Extended friend declarations | N1791 | 4.7 | 2.9 | 16.0* | Yes | 4.1 |
11.1 (partial)
12.0 |
2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.25 | ||
long long
|
N1811 | Yes | Yes | 14.0* | Yes | Yes | Yes | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | Yes | Yes | Yes | Yes | |
| auto | N1984 | 4.4 | Yes | 16.0* | Yes | 3.9 |
11.0
(partial)*
12.0 |
2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.25 | ||
| Delegating constructors ( FTM ) * | N1986 | 4.7 | 3.0 | 18.0* | Yes | 4.7 | 14.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.28 | ||
| extern template | N1987 | 3.3 | Yes | 12.0* | Yes | 3.9 | 9.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.25 | ||
| constexpr ( FTM ) * | N2235 | 4.6 | 3.1 | 19.0 (2015)* | Yes | 4.6 |
13.0 (partial)
14.0 |
2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 |
12.1 (partial)
13.1 |
5.13 | A.06.28 | ||
char16_t
and
char32_t
(
FTM
)
*
|
N2249 | 4.4 | 2.9 | 19.0 (2015)* | Yes | 4.4 |
12.1 (partial)*
14.0 |
2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | A.06.27 | 8.52 | |
| Compiler support for type traits . N2255* |
N2255
N2984 N3142 |
4.3 (partial)*
4.8 (partial)* 5 |
3.0 |
14.0*
(partial)* 19.0 (2015)* |
Yes | 4.0 | 10.0 | 2015 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.3 | 5.13 | 6.16 | |||
| Template aliases ( FTM ) * | N2258 | 4.7 | 3.0 | 18.0* | Yes | 4.2 | 12.1 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | A.06.27 | ||
| alignas | N2341 | 4.8 | 3.0 | 19.0 (2015)* | Yes | 4.8 | 15.0 | 2015 | 7.0 | 8.6 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | |||
| alignof | N2341 | 4.5 | 2.9 | 19.0 (2015)* | Yes | 4.8 | 15.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | |||
| Defaulted and deleted functions | N2346 | 4.4 | 3.0 | 18.0* | Yes | 4.1 | 12.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1 | 5.13 | A.06.25 | ||
Strongly-typed
enum
|
N2347 | 4.4 | 2.9 |
16.0*
(partial)
17.0* |
Yes | 4.0 | 13.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 12.1 | 5.13 | A.06.25 | ||
| Atomic operations | N2427 | 4.4 | 3.1 | 17.0* | Yes | Yes | 13.0 | 2015 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.14 | ||||
| nullptr | N2431 | 4.6 | 2.9 | 16.0* | Yes | 4.2 | 12.1 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1 | 5.13 | A.06.27 | 8.52 | |
| Explicit conversion operators | N2437 | 4.5 | 3.0 | 18.0* | Yes | 4.4 | 13.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 12.1 | 5.13 | A.06.27 | ||
| ref-qualifiers ( FTM ) * | N2439 | 4.8.1 | 2.9 | 19.0 (2015)* | Yes | 4.7 | 14.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.28 | ||
| Unicode string literals ( FTM ) * | N2442 | 4.4 | 3.0 | 19.0 (2015)* | Yes | 4.7 | 11.0* | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 |
10.1*
13.1.1* |
5.7 | A.06.28 | 8.52 | |
| Raw string literals ( FTM ) * | N2442 | 4.5 | Yes | 18.0* | Yes | 4.7 | 14.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.1, except AIX xlC 13.1.3* | 5.13 | A.06.28 | 8.52 | |
| Inline namespaces | N2535 | 4.4 | 2.9 | 19.0 (2015)* | Yes | 4.5 | 14.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.28 | ||
| Inheriting constructors ( FTM ) * | N2540 | 4.8 | 3.3 | 19.0 (2015)* | Yes | 4.8 | 15.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | |||
| Trailing function return types | N2541 | 4.4 | 2.9 | 16.0* | Yes | 4.1 | 12.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 12.1 | 5.13 | A.06.27 | ||
| Unrestricted union s | N2544 | 4.6 | 3.0 | 19.0 (2015)* | Yes | 4.6 | 14.0* | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.28 | ||
| Variadic templates ( FTM ) * |
N2242
N2555 |
4.3
(partial)*
4.4 |
2.9 | 18.0* | Yes |
4.3
(partial)*
4.3 |
12.1 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 11.1 (partial)* | 5.13 | A.06.27 | ||
| Expression SFINAE | N2634 | 4.4 | 2.9 | 19.14* | Yes | 4.2 | 12.1 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | |||||
| Local and unnamed types as template parameters | N2657 | 4.5 | 2.9 | 16.0* | Yes | 4.2 | 12.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.27 | ||
| Thread-local storage | N2659 |
4.4 (partial)
4.8 |
3.3* |
16.0*
(partial)
19.0 (2015)* |
Yes | 4.8 |
11.1 (partial)
15.0* |
2015 | 8.4 | Yes | 17.1.0 | 1.1.0 |
10.1 (partial)*
13.1.2 (partial)* |
5.9 (partial) | 8.52 (partial) | |||
| Dynamic initialization and destruction with concurrency ( magic statics ) ( FTM ) * | N2660 | 4.3 | 2.9 | 19.0 (2015)* | Yes | Yes | 11.1* | 2015 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.25 | |||
| Garbage Collection and Reachability-Based Leak Detection | N2670 | |||||||||||||||||
| Initializer lists ( FTM ) * | N2672 | 4.4 | 3.1 | 18.0* | Yes | 4.5 |
13.0 (partial)
14.0 |
2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.28 | ||
| Non-static data member initializers ( FTM ) * | N2756 | 4.7 | 3.0 | 18.0* | Yes | 4.6 | 14.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.28 | ||
Attributes
,
[[
noreturn
]]
(
FTM
)
*
|
N2761 | 4.8 | 3.3 | 19.0 (2015)* | Yes | 4.2 | 12.1 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | A.06.27 | ||
[[
carries_dependency
]]
|
N2556
N2643 |
3.3* | 17.1.0* | |||||||||||||||
Forward (opaque)
enum
declarations
|
N2764 | 4.6 | 3.1 | 17.0* | Yes | 4.5 |
11.1 (partial)
14.0 |
2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 12.1 | 5.13 | |||
| User-defined literals ( FTM ) * | N2765 | 4.7 | 3.1 | 19.0 (2015)* | Yes | 4.8 | 15.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.14 | |||
| Rvalue references ( FTM ) * |
N2118
N2844 CWG1138 |
4.3
(partial)*
4.5 |
2.9 |
16.0*
(partial)*
17.0* |
Yes | 4.5 |
11.1
(partial)*
12.0 (partial)* 14.0 |
2015 | 7.0* | 8.4 | Yes | 17.1.0 | 1.1.0 | 12.1 | 5.13 | A.06.25 | ||
| Lambda expressions ( FTM ) * |
N2550
N2658 N2927 |
4.5 | 3.1 |
16.0*
(partial)*
17.0* |
Yes | 4.1 | 12.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.25 | ||
| Range-for loop ( FTM ) * |
N2930
N3271 |
4.6 | 3.0 | 17.0* | Yes | 4.5 | 13.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.28 | ||
| noexcept | N3050 | 4.6 | 3.0 | 19.0 (2015)* | Yes | 4.5 | 14.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | A.06.28 | ||
| Defaulted move special member functions | N3053 | 4.6 | 3.0 | 19.0 (2015)* | Yes | 4.5 | 14.0 | 2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 5.13 | A.06.25 | |||
| override and final |
N2928
N3206 N3272 |
4.7 | 2.9 |
14.0*
(partial)
17.0* |
Yes | 4.8 |
12.0
(partial)*
14.0 |
2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | |||
| decltype ( FTM ) * |
N2343
N3276 |
4.3
(partial)*
4.8.1 |
2.9 |
16.0*
(partial)*
17.0* |
Yes |
4.2
(partial)*
4.8 |
11.0
(partial)*
12.0 |
2015 | 7.0 | 8.4 | Yes | 17.1.0 | 1.1.0 | 11.1 (partial)* | 5.13 | A.06.25 | 8.52 (partial)* | |
|
C++11 feature |
Paper(s) |
GCC
|
Clang
|
MSVC
|
Apple Clang
|
EDG eccp
|
Intel C++
|
Nvidia HPC C++ (ex PGI)*
|
Nvidia nvcc
|
Cray
|
Embarcadero C++ Builder
|
IBM Open XL C++ for AIX
|
IBM Open XL C++ for z/OS
|
IBM XL C++
|
Sun/Oracle C++
|
HP aCC
|
Digital Mars C++
|
C++11 library features
|
C++11 feature
|
Paper(s)
|
GCC libstdc++
|
Clang libc++
|
MSVC STL
|
Apple Clang*
|
IBM Open XL C/C++ for AIX*
|
Sun/Oracle C++*
|
Embarcadero C++ Builder*
|
|
|---|---|---|---|---|---|---|---|---|---|
| Regular expressions library | N1429 | 4.9 | 2.8 | Yes | Yes | 17.1.0 | |||
| Type traits . N1836* |
N1836
N2240 N2244 N2255 N2342 N2984 N3142 |
4.3 (partial)*
4.8 (partial)* 5 |
3.0 |
14.0*
(partial)* 19.0 (2015)* |
Yes | 17.1.0 | 5.13 | Yes | |
Member functions
cbegin
,
cend
,
crbegin
, and
crend
of containers
|
N1913
LWG1192 |
4.3
(partial)*
4.5 |
Yes* | 16.0* | Yes* | 17.1.0 | |||
| Garbage Collection and Reachability-Based Leak Detection ( library support ) | N2670 |
6
(no-op)* |
3.4
(no-op)* |
19.0 (2015)*
(no-op)* |
Yes
(no-op)* |
17.1.0 | |||
| Money, Time, and hexfloat I/O manipulators |
N2071
N2072 |
5 | 3.8 | 19.0 (2015)* | Yes | 17.1.0 | 5.15 | ||
| Disallowing COW (copy-on-write) std::basic_string | N2668 | 5 | Yes | Yes | Yes | 17.1.0 | Yes | ||
|
C++11 feature |
Paper(s) |
GCC libstdc++
|
Clang libc++
|
MSVC STL
|
Apple Clang*
|
IBM Open XL C/C++ for AIX*
|
Sun/Oracle C++*
|
Embarcadero C++ Builder*
|
*
- hover over a cell marked with the star
*
to see additional pop-up notes.
DR
nn
- the number
nn
after "DR" denotes target C++ revision the Defect Report is applied to, e.g., DR20 → C++20.
External links
| 1. | C++11 - Wikipedia |
| 2. | Working C++11 examples |