Remarque : la description ci-dessous correspond au cours tel qu'il était à l'époque (2011-2012). Certaines semaines ont maintenant été un peu décalées.
Voir plus bas pour les explications détaillées de chaque aspect.
Course | Feature | dans g++ ?(avec l'option -std=c++11 )
|
Commentaire |
---|---|---|---|
g++ 4.8
|
|||
03 (Variables et opérateurs) | R-value references | yes | Les données ne sont pas que dans des variables, mais peuvent aussi être des «transitoires».
Variable = zone mémoire nommée |
auto-typed variables | yes | indiquer la possibilité. Ne pas en abuser. | |
Generalized const expressions | yes | indiquer la possibilité. | |
04 (structures de contrôle) | range-based for (foreach) | yes | introduire la notation. Peu d'impact ici car nous n'avons pas encore vu de container. |
05 (fonctions) | R-value references | yes | types de passages : par valeur : indiquer la différence qui existe (gérée par le compilateur) entre passage par copie (d'objets existant) et passage par déplacement (de données temporaires). Puis au niveau «avancé» parler de passage par const& et passage par && (niveau encore plus avancé). |
06 (string + tableaux) | std::array | yes | reléguer les build-in en annexe et les remplacer par array
|
Initializer lists | yes | Mentionner l'init par list pour vector et array | |
range-based for (foreach) | yes | remplacer les itérations de base par des range-based | |
Right angle brackets | yes | corriger la typographie des init des vector. | |
Typed enum | yes | les mentionner (en «avancé») | |
long long and other extended integer types | yes | les mentionner | |
07 (structures & pointeurs) | R-value references | yes | parler de référence et r-value référence («avancé») |
nullptr | yes | ||
smart pointers | yes | Note : introduire aussi la notion de référence en soit (cf ci-dessus) | |
std::function | yes | avancé (à la place des pointeurs sur fonctions) | |
12 (listes & piles) | std::forward_list | yes | (en profiter pour mentionner std::stack) |
smart pointers | yes | coder les listes avec des smart ptr (avant de dire que std::forward_list existe) | |
14 (Debuging et exceptions) | Exception specification and noexcept | yes | («avancé») |
16 (Construction + surcharge opérateurs) | Non-static data member init | yes | Mentionner que la syntaxe attribut = valeur; existe, mais ne pas la favoriser... |
Initializer lists | yes | Introduire les constructeurs (et operator= ?) avec init lists | |
Delegating ctors | yes | ||
Default and delete member fctions | yes | ||
Move special member fction | yes | ||
17 (Héritage) | "Heriting" ctors | yes | Dangeureux... (attributs locaux non initialisés) |
18 (polymorphisme) | R-value references | yes | move semantics dans les collections hétérogènes |
Explicit virtual overrides (override et final) | yes | overide : bien mais verbeux, final inutile
|
|
19 (héritage multiple) | R-value references | yes | move semantics dans les collections hétérogènes (remise d'une couche de rappel) |
20 (STL) | std::forward_list | yes | |
std::unordered_map & std::unordered_set | yes | ||
(new) random numbers | yes | ||
21 (Templates) | export | yes | ne plus en parler. Adapter la fin. |
(not C++0x but missing:) template d'int |
(inpired from C++0x Support in GCC - GNU Project - Free Software Foundation (FSF)).
Language Feature | Committee Proposal | Impact (Course #) |
References |
---|---|---|---|
Rvalue references | N2118 |
03 05 07 18 19 |
Rvalue reference @ BS', A Brief Introduction to Rvalue References, Rvalue References and Perfect Forwarding in C++0x, Rvalue-references: the basics, Rvalue-references: how they affect your code, Rvalue references and move constructors, |
Non-static data member initializers | N2756 | 16 |
in wikipedia @ BS' |
Initializer lists | N2672 |
06 16 |
in wikipedia @ BS' |
auto -typed variables |
N1984 | 03 | in wikipedia @ BS' |
Right angle brackets | N1757 | 06 | in wikipedia @ BS' |
Null pointer constant | N2431 | 07 | in wikipedia @ BS' |
Strongly-typed enums | N2347 | 06 | in wikipedia @ BS' |
Generalized constant expressions | N2235 | 03 | in wikipedia @ BS' |
Delegating constructors | N1986 | 16 | in wikipedia @ BS' |
Inheriting constructors | N2540 | 17 | in wikipedia @ BS' |
Defaulted and deleted functions | N2346 | 16 | in wikipedia @ BS' |
Range-based for | N2930 | 04 | in wikipedia @ BS' |
Explicit virtual overrides (overrides et final ) |
N2928
N3206 N3272 |
18 | in wikipedia @ BS' |
C99 Features in C++0x | |||
long long |
N1811 | 06 | in wikipedia @ BS' |
Extended integral types | N1988 | 06 | C wikipedia page |
Library issues | |||
Containers improvements (Move semantics, Init list, emplace , ...) |
06 18 19 |
Container improvements @ BS' | |
std::array |
06 | std::array @ BS' |
|
std::forward_list |
12 20 |
@ BS' | |
std::unordered_map and std::unordered_set |
20 | in wikipedia @ BS' |
|
std::function and std::bind |
7 | in wikipedia @ BS' |
|
Random numbers | 20 | in wikipedia @ BS' |
|
Smart pointers (unique_ptr , weak_ptr , shared_ptr ) |
07 12 |
in wikipedia std::unique_ptr @ BS' std::shared_ptr @ BS' std::weak_ptr @ BS' |
|
Removed features | |||
export (templates) |
21 | ||
Exception specification, noexcept |
14 | @BS' |
Language Feature | Proposal | Impact |
---|---|---|
Rvalue references for *this (& and && qualifier of methods) |
N2439 | - |
Initialization of class objects by rvalues | N1610 | - |
Defining move special member functions | N3053 | - |
Variadic templates | N2242 | - |
Extending variadic template template parameters | N2555 | - |
Static assertions | N1720 | - |
New function declarator syntax (auto ... -> ... ) |
N2541 | - |
New wording for C++0x lambdas | N2927 | - |
Declared type of an expression (decltype ) |
N2343 | - |
Default template arguments for function templates | DR226 | - |
Solving the SFINAE problem for expressions | DR339 | - |
Template aliases | N2258 | - |
Extern templates | N1987 | - |
Forward declarations for enums | N2764 | - |
Generalized attributes | N2761 | - |
Alignment support | N2341 | - |
Explicit conversion operators | N2437 | - |
New character types | N2249 | - |
Unicode string literals | N2442 | - |
Raw string literals | N2442 | - |
Universal character name literals | N2170 | - |
User-defined literals | N2765 | - |
Standard Layout Types (POD revisited) | N2342 | - |
Extended friend declarations | N1791 | - |
Extending sizeof |
N2253 | - |
Inline namespaces | N2535 | - |
Unrestricted unions | N2544 | - |
Local and unnamed types as template arguments | N2657 | - |
Minimal support for garbage collection and reachability-based leak detection | N2670 | - |
Allowing move constructors to throw [noexcept] | N3050 | - |
New algorithms (for_... , init. list in min /max , minmax , ...) |
Algorithms improvements @ BS' | - |
Concurrency | ||
Sequence points | N2239 | - |
Atomic operations | N2427 | - |
Strong Compare and Exchange | N2748 | - |
Bidirectional Fences | N2752 | - |
Memory model | N2429 | - |
Data-dependency ordering: atomics and memory model | N2664 | - |
Propagating exceptions | N2179 | - |
Abandoning a process and at_quick_exit | N2440 | - |
Allow atomics use in signal handlers | N2547 | - |
Thread-local storage | N2659 | - |
Dynamic initialization and destruction with concurrency | N2660 | - |
C99 Features in C++0x | ||
__func__ predefined identifier |
N2340 | - |
C99 preprocessor | N1653 | - |
Library issues | ||
std::tuple |
- | |
Regexp | - | |
unordered_multi... |
- | |
Wrapper reference | - | |
Polymorphic wrapper functions | - | |
type traits | - | |
result_of |
- | |
... | - | |
Removed features | ||
Removal of auto as a storage-class specifier | N2546 | - |
Uniform initialization syntax and semantics, Initializer lists: use it, but don't abuse it! Use it: en particulier l'initialisation des tableaux dynamiques est maintenant simplifiée ! Do not abuse: int i{4}; (déjà possible avant) ne me semble pas des plus clairs conceptuellement ni pédagogiquement... Notice that init lists prevent narrowing, see here. Attention à la différence : vectorv1(7); vector v1{7}; X x{e} est la même chose que X x({e}). Je préfère présenter {e} comme un ensemble de valeurs. Recommendation (débutants) : toujours écrire X x({e}) (voir Stroupstroup pour toutes les équivalences (ici et ici) ( "C++ offers several ways of initializing an object depending on its type and the initialization context. When misused, the error can be surprising and the error messages obscure." ) ) Generalized const expressions (consexpr) : je ne parle pas des fonctions constantes : cela présente à mon avis peu d'intérêt pour les débutants (utilisation d'un appel dans un cas de constante syntaxique, e.g. switch). Me semble vraiment pertinent pour l'optimisation des constructeur et peut être la surcharge des opérateurs. Trop subtil pour un premier cours. Boucles : range for : http://www.stroustrup.com/C++11FAQ.html#for auto -> introduire de suite les boucles par itérateurs ?? see also Container improvements @ BS' Container improvements: ne pas parler de emplace : trop avancé. La move semantics de push_back suffit pour ce cours. (implicit) ctor inheritence : recommendation : ne le faire que si pas de nouveaux attributs !! Sinon : faire appel explicite du Ctor de la super classe (sinon nouveaux attributs ne seront pas init par using superclasse::ctr !!) enum class : TB deprecated throw-specifications (e.g., throw(), throw( Base, Derived1)). Added noexcept (minor : ´A non-inline function is the one place a ‘throws nothing’ [i.e., throw()] exception-specification may have some benefit with some compilers) Rvalue-ref and move semantic: (In C++03, non-const references can bind to lvalues, const references to lvalues or rvalues, but there is nothing that can bind to a non-const rvalue.) From a casual programmer's perspective, what we get from rvalue references is more general and better performing libraries. /!\ Explicitely defaulting a copy ctor like, e.g., A(const& A) = default; will REMOVE the default move ctor (and same for the other way round, and same for operator=) /!\ *NAMED* rvalue references are treated as lvalues when used (e.g. X&& x...; f(x) => uses f(const X&), not f(X&&) !) ==> au niveau débutant : ne pas utiliser explicitement de rvalue ref. Résumé : lvalues and lvalue references, both const and non-const, bind to foo(const A&) const rvalues and const rvalue references bind to foo(const A&) named rvalue references bind to foo(const A&) ONLY non-const rvalues or unnamed rvalue references bind to foo(A&&) a non const lvalue reference CAN NOT bind a rvalue reference move semantics is not useful for classes that do not own ressources (e.g. contains only PODs), copy construction is already optimal when copying from rvalues. move(): The most important implication of this is that we can efficiently return a container from a function move(x) : attention rend x invalide !! When explicitely declare f(X&& x) ? (as opposed to f(X const& x) ) -> when x has to be modified even as a TEMPORARY (otherwise f(X&) is fine enough) -> when the use of TEMPORARY can be chained (otherwise f(X const&) is fine enough). E.g. compare add(Matrix const& x, Matrix const& y) with any of these add(Matrix&& x, Matrix&& y) add(Matrix&& x, Matrix const& y) add(Matrix const& x, Matrix&& y) In the first case, a NEW matrix (the result a+b) MUST be constructed/allocated. In the 3 other cases, an optimization can take place, using the place already allocated for the temporary (using e.g. operator+=). This is what I call "chaining the use of temporary" (maybe a bad expression) Advanced tricky notice: what about f(X const&& x) ? -> this is only usefull if you want to force lvalues, i.e. make sure something DOES NOT bind to an rvalue (remember that an rvalue binds to a const lvalue reference). Then do f(X const&& x) = delete so that f(X const& x) will only get "real" lvalues, not rvalues (as rvalues strongly prefer binding to rvalue references and modifiable expressions prefer weakly binding to non-const references. Thus even non-const rvalues will bind to the deleted prototype) std::forward_list (instead of list, qui est 2bled linked [en mentionner l'existence]) default init values (In-class member initializers) : Je ne suis pas sûr de vouloir montrer cela : confusion de concepts, mais d'un autre coté sont déjà utilisés spontanément par les étudiants (les moins à l'aise)... ...semble donc intuitif.
decltype() : pb de confusion avec decltype(v[0]), decltype((x)) [qui sont des REF !]