Zero-cost version-dependent function call at -O0.

Guillaume Piolat via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 25 23:44:01 PDT 2017


On Sunday, 25 June 2017 at 15:58:48 UTC, Johan Engelen wrote:
>
> In C, you could do something like:
> ```
> #if X
>   void foo() {......}
> #else
>   #define foo()
> #endif
> ```

Curious no one has mentionned it.
Just use alias.

version(X)
     alias myFunc = impl1;
else
     alias myFunc = impl2;

I do it a lot for ldc.intrinsics else they don't provide speed 
benefits, often not being inlined.


More information about the Digitalmars-d-learn mailing list