In C# or Java, the following does not compile, because I "forgot" the where
part in class declaration, that specifies that T is instance of something that defines the add
method.
class C<T> {
T make(T t) {
return t.add(t);
}
}
I'd like to get similar compile-time check in C++, if I specify incomplete requires
for a template argument.
template <typename T>
requires true
class C {
public:
T make() {
return T{};
}
};
I'd like to get a compile error for the C++ code above, stating that method c.make
relies on T
being default-constructible, which is however not captured in the requires
constraints on T
.
Can I get the compiler to check that my set of requires
constraints is sufficient to cover everything the class implementation does?
I am using gcc (GCC) 10.0.0 20191207 (experimental) for this.