How it works...

To best explain how C++20 Concepts will aid in template programming, we will start with a simple example of programming an interface in C++ today. Interfaces define a contract between the implementation of an Application Programming Interface (API) and the user of the API and are heavily used in object-oriented programming to abstract away the interface of an API from its implementation details.

Let's start with the following pure virtual interface:

class interface{public:    virtual ~interface() = default;    virtual void foo() = 0;};

The preceding pure virtual interface in C++ defines a foo() function. Clients of this API do not need to know how foo() is implemented. All they care about is the definition of the interface and the ...

Get Advanced C++ Programming Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.