C++(20) Concepts has superseded the functionalities from #202204181611, #202204181536 and #202204182011. It could be defined as follows using concept
keyword:
template<typename T>
concept Equality_comparable = requires(T a, T b) {
{ a == b } -> bool; // compare Ts with == which return boolean
{ a != b } -> bool; // compare Ts with != which return boolean
}
It could be used to restrict the type which must matched the defined characteristics. Sort of like 202204061235. We could use it in a template like below:
template<Equality_comparable T>
bool is_zero(T a) {
return a == 0;
}
If we use it directly, concept
will always return boolean. For example:
static_assert(Equality_comparable<int>); // true
struct S { int s; };
static_assert(Equality_comparable<S>); // false