What’s New in: C++11/14/17/20 a.k.a. Modern C++

Interested? Contact us!
3 days
SEK 19.900

Request more information

Lena Bernhardsson – SE, DK, NO
+46 (0) 40 59 22 09
lena.bernhardsson@nohau.se

Heidi Lehtomäki – Finland
phone: +358 40 196 0142
heidi.lehtomaki@nohau.fi

Overview:

In September 2011 the standard ISO/IEC 14882:2011 – aka C++11 – was settled. We saw the beginning of the era of “Modern C++”. “Modern C++”: A designation that has been given to this major revision, and the succeeding revisions of the C++ standard. We had a revolution with C++11. With the revisions C++14 and C++17, C++20 and the upcoming C++23 – we see an evolution. The timeline below illustrates this.

C++98C++11C++14C++17C++20C++23

o Templates

o Exceptions

o iostream-API

o std-library string, containers, algorithms

 

o Rvalue references with move semantics

o Lambdas

o Variadic templates

o Uniform initialization

o Type inference (auto)

o Range-based for loop

o constexpr

o std-library APIs support move semantics, smart pointers, concurrency, hash-based containers, atomic<>

 

o Binary literals

o Generalized return type deduction

o Generalized lambda captures

o Generic lambdas

o Relaxed constexpr restrictions

o Heterogeneous lookup in associative containers

o std-library make_unique(), transformation _t alias “shortcuts”

 

o Structured bindings

o if and switch with initialization

o Compile-time static if constexpr

o Aggregate extensions

o Fold expressions

o Mandatory copy elision

o Class template argument deduction

o std-library optional<>, variant<>, any<>, byte, string_view

o File system library

o Parallel STL algorithms

 

o Concepts

o Modules

o Three-way comparison operator <=>

o Expanded constexpr: virtual functions, try and catch, …

o consteval and constinit

o Coroutines

o std-library <ranges>, atomic smart pointers, span, bind_front, format, constexpr-extensions

 

o …

 

Looking upon the number of features brought in since C++11 and think about their impact, one can conclude: Pre-Modern C++ – aka Classical C++ – and Modern C++ are two different languages. To quote Bjarne Stroustrup: “C++11 feels like a new language”.

Modern C++ emphasizes:

• Type inference with auto instead of explicit type names.
• Stack-based scope instead of heap or static global scope – profoundly applying the RAII idiom.
• std-library smart pointers instead of naked raw pointers.
• std-library string- and wstring-types instead of raw arrays of char and wchar_t respectively, and std::string_view to unify std::string and c-string based APIs.
• std-library containers like vector, and unordered_map instead of raw arrays or “home-made” containers.
• std-library algorithms instead of “hand-coded” ones.
• Range-based for loops to write more robust loops that work with arrays and containers.
• Exceptions, to deal with recoverable error conditions.
• Local lambda functions instead of separately implemented functions or function objects.
• Lock-free mutual exclusion using std-library atomic<> instead of alternative mutual exclusion mechanisms.

Goal/Benefits:

This training picks up where an intermediate C++-training would end. The main themes are maintainability and testability.

Furthermore, we will explore many issues and features in C++ like:
• Writing code with testability in mind
• Understand the importance of thorough memory management
• Write generic code using templates
• Get more acquainted with the C++ standard library so that “a lot of home-made coding can be avoided”
• Reasoning about sound and robust APIs where, for instance, raw memory shall never be exposed.
We summarize the training by reasoning about and concluding how a “good” API shall look like.

Audience/Participants:

This training is aimed experienced C++-programmers who want to comprehend and deepen the knowledge in Modern C++.

Previous Knowledge:

The course requires basic skill, at least 3 years’ experience, in C++ programming.

Practical Exercises:

During the training you will practice the presented topics in a few exercises.
We will write unit tests as a natural part of each exercise.
We will use the open and free integrated development environment from Eclipse.

 

Outline:
A. Core Language Extensions –

-Runtime Performance
-Enhancements
▪ Rvalue References and Move Semantics
▪ Generalized Constant Expressions – constexpr, consteval, constinit
• C++14 Relaxed Restrictions
▪ Expanded constexpr
• Virtual Method
• try-catch Block
▪ Plain Old Data (POD) Definition

B. Core Language Extensions – Usability Enhancements
▪ Initializer Lists
▪ Uniform Initialization
▪ Type Inference
▪ Range-based for Loop
▪ Lambda Functions and Expressions
• Generalized Lambda Captures, Generic Lambdas
• Lambda Capture of *this by Value
▪ Alternative Function Syntax
• Generalized Return Type Deduction
▪ Constructor Delegation
▪ In-class Member Initializers
▪ Constructor Inheritance
▪ Explicit override and final
▪ Null Pointer Constant
▪ Strongly Typed enum
▪ Right Angle Bracket
▪ Explicit Conversion Operators
▪ Template Aliases
▪ Structured Bindings
▪ Initialization Statement for if and switch
▪ Aggregate Extensions
▪ Copy Elision
▪ Three-way Comparison: operator <=>
▪ Coroutines

C. Core Language Extensions – Functionality Improvements
▪ Variadic Templates
▪ Variable Templates
▪ Objects as Template Parameters
▪ Static Assert
▪ String Literals – String, Binary, Digit Separator
▪ User-defined Literals
▪ Multithreading Memory Model
▪ Thread-local Storage
▪ Type long long [int]
▪ Explicitly deleted and defaulted Special Member Functions
▪ Apply sizeof on Type Member
▪ Control and Query Object Alignment
▪ Attributes
▪ Class Template Argument Deduction
▪ Compile-Time if constexpr
▪ Fold expressions
▪ Concepts

D. Standard Library Changes and Extensions
▪ Upgrades to Standard Library Components
▪ Threading Facilities
▪ Tuple Types
▪ Hash Tables – aka Unordered Collections
▪ Heterogeneous Lookup in Associative Containers
▪ Regular Expressions
▪ General-purpose Smart Pointers
• Atomic Shared Pointers
▪ Convert Pointer to Raw Pointer: std::to_address()
▪ Extensible Random Number Facility
▪ Wrapper Reference
▪ Polymorphic Wrappers for Function Objects
▪ Type Traits for Metaprogramming
_t Alias “Shortcuts”
_v Alias “Shortcuts”
▪ Alternatives
▪ String Views
▪ File System
▪ Parallel Algorithms
byte
▪ Spans
▪ Text Formatting
▪ Currying – bind_front()
constexpr Library
▪ <ranges> Lazy Evaluation: Yes!

Do you wish more information!

Contact us for offers, information or advice!