2 ms·
Can you elaborate slightly on how you're planning on using _Generic to turn runtime dispatches into compile time ones? I'm not quite putting together how you c
by jesse__ 4y ago
Can you elaborate slightly on how you're planning on using _Generic to turn runtime dispatches into compile time ones? I'm not quite putting together how you can do that.
- lelanthran 4y agoThe example from the wikipedia page for C11 (https://en.wikipedia.org/wiki/C11_(C_standard_revision)#Changes_from_C99 https://en.wikipedia.org/wiki/C11_(C_standard_revision)#Chan...) is compile time determination of the function to call: #define cbrt(x) _Generic((x), long double: cbrtl, \ default: cbrt, \ float: cbrtf)(x) In code you'll write `cbrt(foo)` and the correct function will be called for the type of foo. As I understand it, the `_Generic` selection is performed at compile time.