Subsumption and Negations
Explore the role of subsumption and negations in C++20 Concepts, understanding how the compiler selects the most constrained template overload. Learn to define negation expressions using separate concepts to ensure clear and unambiguous constraint resolution.
We'll cover the following...
We'll cover the following...
Do subsumptions and negations matter?
Subsumptions and negations matter when there are multiple versions of the same method differentiated only by their constraints. Then, the compiler has to look for the most constrained version. Let’s assume that we have a class Ignition with two versions of the start method:
template <typename Key>
class Ignition {
public:
void start(Key key) requires (!Smart<Key>) {}
void start(Key key) requires (!Smart<Key>) && Personal<Key> {}
};
...