Discussion about this post

User's avatar
Caden Parker's avatar

The template header approach actually seems pretty elegant. I typically program in C-style C++ and just use the occasional template. That obviously comes with the bad error messages and not great debugging info, but it's very rare that I need to make a function/type truly generic in that way.

If you needed to program in C and want actual generic types, I think the Ryan Fleury method of having a metaprogram step is probably the best way to go. Abusing the macro system can only get you so far 😅

Expand full comment
msa's avatar

Thank you for the informative article. I believe the "Type Erasure Idiom" should not be classified as "MEH tier". because whenever you want to achieve generics in C, you will likely use it.

Expand full comment
2 more comments...

No posts