...

/

Defining Concepts

Defining Concepts

Learn how to define your own concept.

When the concept you are looking for is not one of the predefined concepts in C++20, you must define your own concept. In this section, I will define a few concepts which will be distinguishable from the predefined concepts through the use of CamelCase syntax. Consequently, my concept for a signed integral is named SignedIntegral, whereas the C++ standard concept goes by the name signed_integral.

The syntax for defining a concept is straightforward:

Press + to interact
template <template-parameter-list>
concept concept-name = constraint-expression;

A concept definition starts with the keyword ...