|
When you call a template function with the wrong arguments, the default error message points to the implementation of the template, and buries the true problem in a list of "required from here" / "included from here" notes.
In C++20 we can use concepts and 'requires' clauses to improve these error messages. For example, if we add this clause:
template <typename T, typename... Args>
|
requires(std::constructible_from<T, Args...>)
|
static PolyValue make(Args&&... args) {
|
return PolyValue{ControlBlockVTable<T, Ts...>::make(std::forward<Args>(args)...)};
|
}
|
then a misuse like ABT::make<Variable>(5) would be caught at the call site, instead of in polyvalue.h.
Another good candidate is algebra::transport. Specifying its requirements is probably harder because its interface has many different options. But that complex interface is also why improving its error messages would be so useful.
|