为什么C++ class
满足EqualityComparable
概念不允许在switch
- case
声明中使用?这个决定背后的理由是什么?为什么switch-case语句在Equality-Comparable类上不允许?
这里遵循EqualityComparable
定义:
template <class T>
concept bool EqualityComparable() {
return requires(T a, T b) {
{a == b} -> Boolean; // Boolean is the concept defining a type usable in boolean context
{a != b} -> Boolean;
};
}
是类构造函数'constexpr'? – StoryTeller
考虑添加'language-lawyer'标签 – alexeykuzmin0
@Quentin - [Not quite](http://eel.is/c++draft/stmt.switch#:label,case)。 – StoryTeller