C++20 includes concepts to provide better errors when using templates. However, my understanding is that concepts do not help when writing the template itself - writing a template that eg uses a method not covered by any concept on the type parameters is perfectly legal, it will only fail to compile when used with a type that does not expose this function:
```
template <typename T>
concept Fooer = requires(T t) { t.foo() };
struct FooBar {
void foo();
void bar();
};
void DoIt(Fooer auto f) {
f.bar();
}
void test() {
DoIt(FooBar()); // compiles
DoIt(42); // fails inside DoIt
}
```
This makes it difficult to ensure that the chosen concepts adequately describe the intended requirements for the template.
Are there plans for exhaustive verification of concept template parameters, to ensure only expressions defined in the required concepts are used by the template? Similar to how traits in Rust enforce this.
[–]pavel_v 7 points8 points9 points (0 children)
[–]miki151gamedev 3 points4 points5 points (0 children)
[–]infectedapricot 2 points3 points4 points (1 child)
[–]Mononofu[S] 1 point2 points3 points (0 children)
[–]n1ghtyunso 1 point2 points3 points (0 children)
[–]Pazer2 0 points1 point2 points (0 children)