0Pricing
C++ Academy · Lesson

Using Concepts in Templates and auto

Constrain function templates and abbreviated function templates with concepts.

Three Syntaxes Recap

You can apply a concept three ways: as a template parameter prefix, as a requires clause, or with abbreviated function template syntax.

Prefix Syntax

Replace typename with the concept name.

template <std::integral T>
T add(T a, T b) { return a + b; }

All lessons in this course

  1. Why Concepts vs SFINAE
  2. Defining Concepts with requires
  3. Using Concepts in Templates and auto
  4. Common Standard Concepts Integral Ranges
← Back to C++ Academy