C1X going forward

Walter Bright newshound2 at digitalmars.com
Mon May 9 14:59:50 PDT 2011


On 5/9/2011 12:02 AM, Iain Buclaw wrote:
> _Generic is a somewhat interesting feature of C1X too, though I can't imagine ever
> using any of the new features they've proposed.
>
> #define sqrt(X) _Generic((X), long double: sqrtl, \
>                                default: sqrt, \
>                                float: sqrtf)(X)
>
> float a = 25;
> auto b = sqrt(a);   // calls sqrtf

This cure is worse than the disease.

Either put in real overloading, or not. Not this.


More information about the Digitalmars-d mailing list