- Templates (compile time), which are generic bits of code that are monomorphized over every combination of template parameters that they're used with.
- Virtualization (runtime), classic OO style polymorphism with a VTable (I think this similar to Rust's dyn trait?).
I think they meant to say that neither templates (nor virtual classes) are quite up to the same level of polymorphism that Rust has. Ie Rust type checkes at definition, as opposed to copy-paste and hope for the best (wrgt templates) when trying to compile the code. In other words Cpp templates are closer to Rusts declarative macros than to Rust generics. Hopefully concepts make this better in Cpp.
As always in C++ world, there is a workaround with static analysis, which could give errors when template code reaches out to capabilities that aren't part of the concept definition.
Does such a static analysis exist? I think the most realistic solution is to write an archetype class for each concept and instantiate each template with its relevant archetypes.
Now can we automate writing archetypes from concepts (and viceversa)? Maybe in C++64 when we finally get static reflection.
I really hate how C++/WinRT used the "C++ reflection is around the corner" excuse to kill C++/CX and downgrade the COM development experience back to pre-.NET days.
Apparently it isn't around the corner.
However with type traits and a bit of constexpr if (requires {....}) it is possible to have a kind of poor man's compile time reflection.
- Templates (compile time), which are generic bits of code that are monomorphized over every combination of template parameters that they're used with.
- Virtualization (runtime), classic OO style polymorphism with a VTable (I think this similar to Rust's dyn trait?).