Predefined Concepts - Part I
Get an overview of important predefined concepts.
The golden rule “Don’t reinvent the wheel” also applies to concepts. The C++ Core Guidelines are very clear about this rule:
T.11: Whenever possible use standard concepts.
Consequently, I want to give you an overview of the important predefined concepts. I intentionally ignore any special or auxiliary concepts.
All predefined concepts are detailed in the latest C++20 working draft, N4860, and finding them all can be quite a challenge! Most of the concepts are in the concepts library and ranges library. Additionally, a few concepts are in the language support library, general utilities library, iterators library, and numerics library. The C++20 draft N4860 also has an index to all library concepts and shows how the concepts are implemented.
Language support library
This section discusses an interesting concept, three_way_comparable
. It is used to support the three-way comparison operator. It is specified in the header <compare>
.
More formally, let a
and b
be values of type T
. These values are three_way_comparable
only if:
- (a <=> b == 0) ==