This course teaches you how to use the advanced object programming paradigms in C++ variants 11, 14, and 17. The course builds on basic C++ knowledge that enables you to utilize constructs such as move semantics, lambdas, templates, etc. in their C++ software solutions. Thanks to these high-level OOP, C++ is great to model complex systems, such as autonomous driving systems in vehicles.
M1: Selected new C++ features
https://academy.nit-institute.com/wp-content/uploads/2024/08/Moderncpp1.png
We start learning about Modern C++ by getting to know smaller new features and keywords that can be illustrated quickly and easily, such as: nullptr, auto, constexpr, enum class, static_assert, range for, etc. Special attention is given to constexpr and auto, because they have an extremely significant impact on writing C++ programs. (Keyword auto is also covered some more later in the course.)
A warming up task will require you to adopt custom data structure so that it can be iterated using “range for” syntax. In the second task you will play with a constexpr function to gently start to understand that feature.
4 hours
M2: Selected new C++ features for better class design
https://academy.nit-institute.com/wp-content/uploads/2024/08/Moderncpp2.png
In this module, several different novelties are covered that facilitate the design of the class, i.e. types. They provide more control over type behavior, but also help to catch some common errors. The ability to create user literals is very important and we cover it in detail. It raises the expressiveness that a user type can provide on par with built-in types. Finally, we will get to know the new standard chrono library, which is useful and interesting by itself, but also illustrates usage of user defined literals.
A single task is given of completing the definition of a class, so that you use some of the features covered by the module, and – of course – user defined literal.
4 hours
M3: Move semantics, rvalue reference, smart pointers and noexcept
https://academy.nit-institute.com/wp-content/uploads/2024/08/Moderncpp3.png
This module covers a lot of ground. Firstly, we will see an important novelty: move semantics (which represents perhaps the biggest novelty for better type design), as well as rvalue references, written as && (a language extension that is actually behind move semantics and has a few more useful applications, such as “forwarding reference”). Secondly, with the understanding of move semantics, we look closely at “smart pointers” – a great example of move semantic utilization from the standard library (plus they’re useful). We also illustrate the use of the noexcept keyword, also explaining the importance of emphasizing that a function does not throw any exceptions.
Firstly you will need to “move enable” the class from the previous module’s exercise, and then, in the second task, you will implement a (slightly simplified) version of std::unique pointer.
5 hours
M4: Lambda expressions
https://academy.nit-institute.com/wp-content/uploads/2024/08/Moderncpp4.png
Function objects, or functors, are objects that can be syntactically used as functions. This is achieved by overloading the function call operator “()”. Even before the 2011 standard, function objects were used in C++ code, but since 2011, with the introduction of lambda expressions, their use has increased significantly, and they started appearing in simpler programs as well. The 4th module explains this important element of Modern C++, with the related features like: capture, generic lambdas, trailing return type…
A set of simple tasks is given but they need to be implemented using lambda expressions. While solving these tasks you will also need to learn and use algorithm library.
4 hours
M5: Multithreading
https://academy.nit-institute.com/wp-content/uploads/2024/08/Moderncpp5.png
In this module we cover some basic topics related to multithreading. Learn how to work with threads using standard library, and how to utilize promise/future mechanism for asynchronous execution. From the standard library we illustrate: std::thread, std::mutex, std::lock_guard, std::scoped_lock, std::unique_lock, std::condition_variable, std::semaphore.
Two tasks are given. One for you to get a hands-on experience with creating and joining threads, and the other for you to get familiar with mutex and locks, as well as promise and future.
4 hours
M6: Generic programming and metaprogramming 1
https://academy.nit-institute.com/wp-content/uploads/2024/08/Moderncpp6.png
In this module we start covering the topic of advanced generic programming and metaprogramming. Several important novelties have been introduced in that area since 2011. One of the key ones is the ability to define templates with a variable number of arguments, called “variadic templates”. This enabled some new elements of the standard library, such as tuples. We also show “fold expression” syntax, how to work with “parameter packs”, usage of sizeof…, and the if constexpr construct that makes writing templates much easier in some cases.
Two simple tasks are given to let you practice variadic templates. There is also an optional task that will require you to implement printf, from C, but which checks that types expected by the format string match types of the actual arguments. Not a simple task, but you will learn a lot.
4 hours
M7: Generic programming and metaprogramming 2
https://academy.nit-institute.com/wp-content/uploads/2024/08/Moderncpp7.png
In this module we continue the topic of generic programming and metaprogramming. We’ll see some more of the type_traits header, template specialization, and new kinds of templates: variable template and alias template. Another important novelty that we cover is argument deduction guides. This novelty enables the inference of template arguments to happen not only when instantiating function templates, but also when instantiating class templates. Finally, two important template related techniques will be illustrated: static polymorphism and CRTP.
This exercise is purely optional. One big task that will require you to combine knowledge from a few different modules of this course.
3 hours 30 minutes
Final exam
none
none
none
1 hour 30 minutes