4 ms·
Concepts give you something like this for template parameters, so instead of saying template<typename T> you can say template<Numeric T> where this would constr
by mattnewport 9y ago
Concepts give you something like this for template parameters, so instead of saying template<typename T> you can say template<Numeric T> where this would constrain the template to only be instantiable with type satisfying the Numeric concept. There's also some syntactic sugar where you can just say auto f(Numeric x) and this means template<Numeric T> auto f(T x).
Concepts are in the process of standardization and are expected to be part of C++20.
This is nothing to do with inheritance though in C++. Concepts are type constraints and don't require any particular inheritance hierarchy which is a much better way to handle things than using inheritance for this purpose.
- vanderZwan 9y agoThanks for the explanation! I vaguely remember reading about concepts and didn't quite get how they would be used in practice, but this seems like a good example.