An Introduction to Concepts and Constraints

Get introduced to the topics such as requires expressions, composing constraints, and more.

We'll cover the following

The C++20 standard provides a series of significant improvements to template metaprogramming with concepts and constraints. A constraint is a modern way to define requirements on template parameters. A concept is a set of named constraints. Concepts provide several benefits to the traditional way of writing templates, mainly improved readability of code, better diagnostics, and reduced compilation times.

Overview of concepts and constraints

In this section, we’ll address the following topics:

  • Understanding the need for concepts

  • Defining concepts

  • Exploring requires expressions

  • Composing constraints

  • Learning about the ordering of templates with constraints

Get hands-on with 1200+ tech skills courses.