|
Any++
|
Any++'s traits can not only be used for external polymorphism via dynamic type erasure, but also for static dispatch and customization points. Just like traits in Rust.
The more general term for this pattern is type class. To illustrate the concept, we will use the "Hello World" of type classes, the "Monoid", as an example.
If you need a little primer or an overview to this theme, please refer this sections:
We will finish with a look into an onging ISO C++ proposal, which when accepted, get us to full checked templates.