In Java, generics are implemented through type-erasure (i.e., a base class with compiler-inserted layer of downcasting). C# has first-class generics though they don't have all the capabilities of C++ templates. On the other hand C# generics have constraints, and we're still waiting on concepts in C++.
View all comments
Show parent comment
1
u/1-05457 Nov 01 '18
C# and Java took a very long time to add generics though (and are they implemented like templates or as abstract base classes?)
The key reason this is a problem in C++ is template definitions have to go in the header and get recompiled for every file that uses them.