C++11
C++11 ist die zweite Hauptversion von C++ und das wichtigste Update seit C++98. Eine große Anzahl von Änderungen wurde eingeführt, um sowohl bestehende Praktiken zu standardisieren als auch die Abstraktionen zu verbessern, die C++-Programmierern zur Verfügung stehen.
Bevor es am 12. August 2011 endgültig von der ISO genehmigt wurde, wurde der Name 'C++0x' verwendet, da erwartet wurde, dass es vor 2010 veröffentlicht würde. Es dauerte 8 Jahre zwischen C++03 und C++11, daher wurde es zum bisher längsten Intervall zwischen Versionen. Seitdem aktualisiert sich C++ derzeit regelmäßig alle 3 Jahre.
| Dieser Abschnitt ist unvollständig |
Folgende Funktionen wurden in C++11 übernommen:
- Von TR1 : gesamtes TR1 außer Spezielle Funktionen .
- Von Boost: Die Thread-Bibliothek , exception_ptr , error_code und error_condition , Iterator-Verbesserungen ( begin , end , next , prev )
- Von C: C-Stil Unicode-Konvertierungsfunktionen
Inhaltsverzeichnis |
Kernsprachfunktionen
- auto und decltype
- defaulted und deleted Funktionen
- final und override
- trailing return type
- rvalue references
- move constructors und move assignment operators
- scoped enums
- constexpr und literal types
- list initialization
- delegating und inherited Konstruktoren
- brace-or-equal Initializers
- nullptr
- long long
- char16_t und char32_t
- type aliases
- variadic templates
- generalized (non-trivial) unions
- generalized PODs ( trivial types und standard-layout types )
- Unicode string literals
- user-defined literals
- attributes
- lambda expressions
- noexcept Specifier und noexcept Operator
- alignof und alignas
- Multithreaded memory model
- thread-local storage
- GC interface (entfernt in C++23)
- range- for (basierend auf Boost-Bibliothek)
- static_assert (basierend auf Boost-Bibliothek)
| Dieser Abschnitt ist unvollständig |
Bibliotheksfunktionen
Header
- <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>
Bibliotheksfunktionen
- Concurrency-Unterstützungsbibliothek
-
emplace()und andere Verwendungen von Rvalue-Referenzen in allen Teilen der bestehenden Bibliothek - std::unique_ptr
- std::move_iterator
- std::initializer_list
- Zustandsbehaftete und Bereichsbezogene Allokatoren
- std::forward_list
- Chrono-Bibliothek
- Ratio-Bibliothek
- Neue Algorithmen :
-
- 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-Konvertierungs-Facets
- std::function
- std::exception_ptr
- std::error_code und std::error_condition
- Iterator Verbesserungen:
| Dieser Abschnitt ist unvollständig |
Fehlerberichte
Compiler-Unterstützung
C++11-Kernsprachfunktionen
|
C++11-Funktion
|
Dokument(e)
|
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 Präprozessor | N1653 | 4.3 | Ja |
19.0 (2015)*
(teilweise)*
19.26* |
Ja | 4.1 | 11.1 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 10.1 | 5.9 | A.06.25 | Ja | |
| static_assert ( FTM ) * | N1720 | 4.3 | 2.9 | 16.0* | Ja | 4.1 | 11.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.25 | 8.52 | |
| Rechtwinklige Klammern | N1757 | 4.3 | Ja | 14.0* | Ja | 4.1 | 11.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 12.1 | 5.13 | |||
| Erweiterte friend Deklarationen | N1791 | 4.7 | 2.9 | 16.0* | Ja | 4.1 |
11.1 (teilweise)
12.0 |
2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.25 | ||
long long
|
N1811 | Ja | Ja | 14.0* | Ja | Ja | Ja | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | Ja | Ja | Ja | Ja | |
| auto | N1984 | 4.4 | Ja | 16.0* | Ja | 3.9 |
11.0
(teilweise)*
12.0 |
2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.25 | ||
| Delegierende Konstruktoren ( FTM ) * | N1986 | 4.7 | 3.0 | 18.0* | Ja | 4.7 | 14.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.28 | ||
| extern template | N1987 | 3.3 | Ja | 12.0* | Ja | 3.9 | 9.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.25 | ||
| constexpr ( FTM ) * | N2235 | 4.6 | 3.1 | 19.0 (2015)* | Ja | 4.6 |
13.0 (teilweise)
14.0 |
2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 |
12.1 (teilweise)
13.1 |
5.13 | A.06.28 | ||
char16_t
und
char32_t
(
FTM
)
*
|
N2249 | 4.4 | 2.9 | 19.0 (2015)* | Ja | 4.4 |
12.1 (teilweise)*
14.0 |
2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | A.06.27 | 8.52 | |
| Compiler-Unterstützung für Type-Traits . N2255* |
N2255
N2984 N3142 |
4.3 (teilweise)*
4.8 (teilweise)* 5 |
3.0 |
14.0*
(teilweise)* 19.0 (2015)* |
Ja | 4.0 | 10.0 | 2015 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.3 | 5.13 | 6.16 | |||
| Template-Aliase ( FTM ) * | N2258 | 4.7 | 3.0 | 18.0* | Ja | 4.2 | 12.1 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | A.06.27 | ||
| alignas | N2341 | 4.8 | 3.0 | 19.0 (2015)* | Ja | 4.8 | 15.0 | 2015 | 7.0 | 8.6 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | |||
| alignof | N2341 | 4.5 | 2.9 | 19.0 (2015)* | Ja | 4.8 | 15.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | |||
| Defaulted und deleted Functions | N2346 | 4.4 | 3.0 | 18.0* | Ja | 4.1 | 12.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1 | 5.13 | A.06.25 | ||
Stark typisierte
enum
|
N2347 | 4.4 | 2.9 |
16.0*
(teilweise)
17.0* |
Ja | 4.0 | 13.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 12.1 | 5.13 | A.06.25 | ||
| Atomare Operationen | N2427 | 4.4 | 3.1 | 17.0* | Ja | Ja | 13.0 | 2015 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.14 | ||||
| nullptr | N2431 | 4.6 | 2.9 | 16.0* | Ja | 4.2 | 12.1 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1 | 5.13 | A.06.27 | 8.52 | |
| Explizite Konvertierungsoperatoren | N2437 | 4.5 | 3.0 | 18.0* | Ja | 4.4 | 13.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 12.1 | 5.13 | A.06.27 | ||
| Ref-Qualifizierer ( FTM ) * | N2439 | 4.8.1 | 2.9 | 19.0 (2015)* | Ja | 4.7 | 14.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.28 | ||
| Unicode String-Literale ( FTM ) * | N2442 | 4.4 | 3.0 | 19.0 (2015)* | Ja | 4.7 | 11.0* | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 |
10.1*
13.1.1* |
5.7 | A.06.28 | 8.52 | |
| Raw String-Literale ( FTM ) * | N2442 | 4.5 | Ja | 18.0* | Ja | 4.7 | 14.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.1, außer AIX xlC 13.1.3* | 5.13 | A.06.28 | 8.52 | |
| Inline-Namespaces | N2535 | 4.4 | 2.9 | 19.0 (2015)* | Ja | 4.5 | 14.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 11.1 | 5.13 | A.06.28 | ||
| Vererbende Konstruktoren ( FTM ) * | N2540 | 4.8 | 3.3 | 19.0 (2015)* | Ja | 4.8 | 15.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | |||
| Nachgestellte Funktionsrückgabetypen | N2541 | 4.4 | 2.9 | 16.0* | Ja | 4.1 | 12.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 12.1 | 5.13 | A.06.27 | ||
| Uneingeschränkte union s | N2544 | 4.6 | 3.0 | 19.0 (2015)* | Ja | 4.6 | 14.0* | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.28 | ||
| Variadic Templates ( FTM ) * |
N2242
N2555 |
4.3
(teilweise)*
4.4 |
2.9 | 18.0* | Ja |
4.3
(teilweise)*
4.3 |
12.1 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 11.1 (teilweise)* | 5.13 | A.06.27 | ||
| Expression SFINAE | N2634 | 4.4 | 2.9 | 19.14* | Ja | 4.2 | 12.1 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | |||||
| Lokale und unbenannte Typen als Template-Parameter | N2657 | 4.5 | 2.9 | 16.0* | Ja | 4.2 | 12.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.27 | ||
| Thread-lokaler Speicher | N2659 |
4.4 (teilweise)
4.8 |
3.3* |
16.0*
(teilweise)
19.0 (2015)* |
Ja | 4.8 |
11.1 (teilweise)
15.0* |
2015 | 8.4 | Ja | 17.1.0 | 1.1.0 |
10.1 (teilweise)*
13.1.2 (teilweise)* |
5.9 (teilweise) | 8.52 (teilweise) | |||
| Dynamische Initialisierung und Destruktion mit Nebenläufigkeit ( Magic Statics ) ( FTM ) * | N2660 | 4.3 | 2.9 | 19.0 (2015)* | Ja | Ja | 11.1* | 2015 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.25 | |||
| Garbage Collection und Erreichbarkeitsbasierte Speicherleck-Erkennung | N2670 | |||||||||||||||||
| Initialisierungslisten ( FTM ) * | N2672 | 4.4 | 3.1 | 18.0* | Ja | 4.5 |
13.0 (teilweise)
14.0 |
2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.28 | ||
| Initialisierer für nicht-statische Datenelemente ( FTM ) * | N2756 | 4.7 | 3.0 | 18.0* | Ja | 4.6 | 14.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.28 | ||
Attribute
,
[[
noreturn
]]
(
FTM
)
*
|
N2761 | 4.8 | 3.3 | 19.0 (2015)* | Ja | 4.2 | 12.1 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | A.06.27 | ||
[[
carries_dependency
]]
|
N2556
N2643 |
3.3* | 17.1.0* | |||||||||||||||
Vorwärtsdeklarationen (opaque)
enum
-Deklarationen
|
N2764 | 4.6 | 3.1 | 17.0* | Ja | 4.5 |
11.1 (teilweise)
14.0 |
2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 12.1 | 5.13 | |||
| Benutzerdefinierte Literale ( FTM ) * | N2765 | 4.7 | 3.1 | 19.0 (2015)* | Ja | 4.8 | 15.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.14 | |||
| Rvalue-Referenzen ( FTM ) * |
N2118
N2844 CWG1138 |
4.3
(teilweise)*
4.5 |
2.9 |
16.0*
(teilweise)*
17.0* |
Ja | 4.5 |
11.1
(teilweise)*
12.0 (teilweise)* 14.0 |
2015 | 7.0* | 8.4 | Ja | 17.1.0 | 1.1.0 | 12.1 | 5.13 | A.06.25 | ||
| Lambda-Ausdrücke ( FTM ) * |
N2550
N2658 N2927 |
4.5 | 3.1 |
16.0*
(teilweise)*
17.0* |
Ja | 4.1 | 12.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.25 | ||
| Bereichsbasierte for-Schleife ( FTM ) * |
N2930
N3271 |
4.6 | 3.0 | 17.0* | Ja | 4.5 | 13.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.2* | 5.13 | A.06.28 | ||
| noexcept | N3050 | 4.6 | 3.0 | 19.0 (2015)* | Ja | 4.5 | 14.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | A.06.28 | ||
| Standardmäßig generierte Move- spezielle Element- funktionen | N3053 | 4.6 | 3.0 | 19.0 (2015)* | Ja | 4.5 | 14.0 | 2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 5.13 | A.06.25 | |||
| override und final |
N2928
N3206 N3272 |
4.7 | 2.9 |
14.0*
(teilweise)
17.0* |
Ja | 4.8 |
12.0
(teilweise)*
14.0 |
2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 13.1.1* | 5.13 | |||
| decltype ( FTM ) * |
N2343
N3276 |
4.3
(teilweise)*
4.8.1 |
2.9 |
16.0*
(teilweise)*
17.0* |
Ja |
4.2
(teilweise)*
4.8 |
11.0
(teilweise)*
12.0 |
2015 | 7.0 | 8.4 | Ja | 17.1.0 | 1.1.0 | 11.1 (teilweise)* | 5.13 | A.06.25 | 8.52 (teilweise)* | |
|
C++11-Funktionalität |
Dokument(e) |
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-Bibliotheksfunktionen
|
C++11-Funktion
|
Dokument(e)
|
GCC libstdc++
|
Clang libc++
|
MSVC STL
|
Apple Clang*
|
IBM Open XL C/C++ for AIX*
|
Sun/Oracle C++*
|
Embarcadero C++ Builder*
|
|
|---|---|---|---|---|---|---|---|---|---|
| Regex-Bibliothek | N1429 | 4.9 | 2.8 | Ja | Ja | 17.1.0 | |||
| Type traits . N1836* |
N1836
N2240 N2244 N2255 N2342 N2984 N3142 |
4.3 (teilweise)*
4.8 (teilweise)* 5 |
3.0 |
14.0*
(teilweise)* 19.0 (2015)* |
Ja | 17.1.0 | 5.13 | Ja | |
Member-Funktionen
cbegin
,
cend
,
crbegin
, und
crend
von Containern
|
N1913
LWG1192 |
4.3
(teilweise)*
4.5 |
Ja* | 16.0* | Ja* | 17.1.0 | |||
| Garbage Collection und Reachability-Based Leak Detection ( Bibliotheksunterstützung ) | N2670 |
6
(no-op)* |
3.4
(no-op)* |
19.0 (2015)*
(no-op)* |
Ja
(no-op)* |
17.1.0 | |||
| Geld-, Zeit- und hexfloat-I/O-Manipulatoren |
N2071
N2072 |
5 | 3.8 | 19.0 (2015)* | Ja | 17.1.0 | 5.15 | ||
| Untersagung von COW (copy-on-write) std::basic_string | N2668 | 5 | Ja | Ja | Ja | 17.1.0 | Ja | ||
|
C++11-Funktionalität |
Dokument(e) |
GCC libstdc++
|
Clang libc++
|
MSVC STL
|
Apple Clang*
|
IBM Open XL C/C++ for AIX*
|
Sun/Oracle C++*
|
Embarcadero C++ Builder*
|
*
- fahren Sie mit der Maus über eine mit dem Stern markierte Zelle
*
, um zusätzliche Pop-up-Notizen zu sehen.
DR
nn
- die Zahl
nn
nach "DR" bezeichnet die Ziel-C++-Revision, auf die der Defektbericht angewendet wird, z.B. DR20 → C++20.
Externe Links
| 1. | C++11 - Wikipedia |
| 2. | Funktionsfähige C++11-Beispiele |