In recent years, the C ++ language has evolved. To stick to the 1998/2003 standard is to miss many new features that make modern C ++ more robust, more powerful, and often more readable.
Through this training, it is proposed to become familiar with syntactic novelties that facilitate the writing of code, modernized best practices to avoid the language traps, and a programming way that is easier to parallelize.
This training is for scientific programmers who want to discover « modern » C ++ (2011 to 2020 standards), and adapt their programming practices accordingly.
Detailed Program :
- Review of some basic C++ concepts, overview of C++ as a software development environment, with two major software engineering strategies: object oriented programming and generic programming.
- Object oriented programming: the virtual function mechanism enabling late binding at execution time, (software modules calling newly written routines without recompilation).
- Examples of the power and relevance of virtual functions
- Function objects as extended pointers to functions, examples
- Introduction to generic programming: function templates, examples
- Generic programming: class templates, examples
- The core of generic programming: using function and class templates to parameterize behavior rather than just object types
- Overview of the Standard Template Library (STL): strategies, containers, iterators, algorithms
- Concurrency in the standard C++ library: overview of the thread class, discussion of the new threading interfaces (futures, promises) enabling easy synchronization of simple concurrency patterns.
Modern C++ syntax
- Basic features: type inference, stronger typing, user-defined literals, uniform initialization, rvalue references, move semantics.
- Object features: member variables initialization, delegated and inherited constructors, explicit deletion and overriding of member functions.
- Generic features: static assertions, template variables and type aliasing, constant expressions, variadic templates, perfect forwarding.
- Functional features: lambda functions.
Modern C++ library
- Basic tools: smart pointers (unique_ptr, shared_ptr), new collections (array, unordered maps), views (span, string_array), wrapper types (function, ref).
- Generic tools: type traits, sfinae, concepts.
- Functional tools: algebraic types (tuple, variant), monadic types (optional, future), ranges.
- Optimization and parallelization: beyond double, random numbers, chrono, execution policies, structures of arrays, co-routines.
Knowledge of classical (pre-11) C++ syntax, and basic experience in programming with C++ objects. Participants should be familiar with the following concepts:
- references, difference with pointers
- basic memory allocation (new and delete)
- Properties of C++ functions (default values, overloading)
- Basic understanding of error handling (exceptions)
- C++ classes, programming with objects, public derivation of classes
- Basic knowledge of templates
Introduction to the Portable, Extensible Toolkit for Scientific Computation (PETSc).