On July 2nd, we plan to run a webinar covering some of the features of Modern C++. Modern C++ is a really broad topic, so here is an outline of some of the things we are going to cover:
- Useful new C++ constructs, such as in-class variable initializers, delegating constructors and deleted/defaulted functions as well as raw strings,
- Uniform initialization, which simplifies the, ahem, initialization of various objects (e.g., obviating some constructor calls in function return values) and also helps us avoid C++’s most vexing parse. Also introduced is the concept of initializer lists.
- Automatic type deduction with auto and decltype keywords drastically reduce the amount of code one has to write, and also help us write powerful generic code.
- The override and final keywords help us control that we are, in fact, overriding a function, or preventing a function from being overridden.
- Lambdas allow us to easily define anonymous functions instead of building old-fashioned functors. They also happen to be more powerful in C++ than in C#/Java: you can, for example, control which variables get captured and how.
- Strongly typed enumerations prevent their elements from polluting their immediate declaration scope and offer additional safety.
Non-member begin()/end() functions simplify writing algorithms that can operate on different collections (e.g., array or
vector) and a range-based for loop, especially coupled with
auto, makes iterating collections a lot easier.
- constexpr and static asserts allow us to perform compile-time evaluations, whereas type traits let us intelligently constrain template parameters.
Variadic templates let you write functions with variable number of arguments of any types, resulting in neat things such as the super-useful
tiefunction that finally lets us extract tuple values in a single statement and without those ugly
Smart pointers have come a long way since the days of
auto_ptr. We’ll talk about the common types (
weak_ptr) and their uses.
Finally, we shall talk about rvalue references and move semantics that help us avoid needless creation of temporary objects. We’ll cover
std::moveand how to write your own move constructors and assignment operators.
So these are some of the things we are going to talk about in the webinar. If you haven’t registered for the webinar yet, please register here and we’ll see you on July 2nd! ■