Where is the list of problems that are easier to solve with generics?
Where is the list of problems that are easier to solve with generics?
Here is a random example from my recent adventures, a channel implementation in C++ which uses generics to provide value-semantics for user-specified message types:
https://github.com/andreas-gone-wild/snackis/blob/master/src...
And here is a column class that uses generics to inject both record type and value type into the implementation:
https://github.com/andreas-gone-wild/snackis/blob/master/src...
Doing any of these without generics would mean either erasing types or writing duplicate code. Go provides generic channels, slices and maps; but it doesn't extend that power to user-code since users are supposedly not smart enough to be trusted with power.
The problem is that you can't create your own generic structure. Try building a statically type-safe red-black tree, or something like that, without copy-pastig the implementation for each new node data type.
Higher-order functions are also basically impossible.
Pointers and slices as well, and of course the various builtin operators or functions used to work on them (make, range, len, close, …).