Quick help on version function parameter

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 18 15:49:25 PST 2015


I'd write a foo_impl which always takes a parameter. Then do the 
versioned foo() functions which just forward to it:

void foo_impl(int x) { long function using x here }

version(globals) {
    int x;
    void foo() {
       foo_impl(x);
    }
} else {
    void foo(int x) { foo_impl(x); }
}

Minimal duplication with both interfaces.


More information about the Digitalmars-d-learn mailing list