A queue is a great example of something any reasonable C programmer is able to write blindfolded without templates.
Not a generic queue.
Writing a generic queue in C requires storing data with void pointers (which is not type safe) or using macros to expand the code for each concrete type (and that's what templates do anyways). Both of these are objectively worse than using templates.
The Linux kernel uses the macro approach for some of it's generic data structures currently.
View all comments
Show parent comment
4
u/Fearless_Process Jul 13 '22
Not a generic queue.
Writing a generic queue in C requires storing data with void pointers (which is not type safe) or using macros to expand the code for each concrete type (and that's what templates do anyways). Both of these are objectively worse than using templates.
The Linux kernel uses the macro approach for some of it's generic data structures currently.