June 2025
Intermediate to advanced
1093 pages
33h 24m
English
Since C++20, there is the possibility to restrict the types you use as template parameters. For this, concepts were introduced. These define language within C++ that allows you to make assertions about template parameters. When you then instantiate (i.e., use) a template, these assertions are checked and acknowledged with a clearer error message than would be possible without a concept.
The standard library comes with a lot of concepts, many of them in the <concepts> header, but also in <iterators>, <ranges>, and so on.
When you look at a function header with a concept, you see something like the following listing.
// https://godbolt.org/z/jP75nY4EW#include <concepts> // integral#include <iostream> ...
Read now
Unlock full access