Hacker News new | past | comments | ask | show | jobs | submit login

Type generic expressions [1] already exist in C11. You can do this without a special compiler front-end if you need it, you would just need to define each variant by hand. These are supported in GCC and Clang with the -std=c11 flag.

[1]: http://www.robertgamble.net/2012/01/c11-generic-selections.h...




I developed these ideas a bit further with the use of XX macros, which allow you to make a set of functions generic across some list of types. There can be real performance wins to this over void*: https://abissell.com/2014/01/16/c11s-_generic-keyword-macro-...


That looks handy. I got bored one day and built a fluent interface: http://flukus.github.io/fluent-interfaces-for-c.html


_Generic has been created for a specific use (tgmath.h) and is not very powerful.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: