Request for forced implicit cast

bearophile bearophileHUGS at lycos.com
Fri Aug 22 08:07:48 PDT 2008


Frank Benoit:
> When it comes to overloaded functions where not all arguments match
> exactly, they must be casted to the arguments types of the method that
> should be used.

Or you may modify your functions:

int foo(T1, T2)(T arg1, T2 arg2) {
    static if (Is!Type(T1, int, long, short) && IsType!(T2, string)) {
        do something
    } else {
        do something different
    }
}

In D 2.x recently there's a new syntax to do similar things in a default way.

Bye,
bearophile



More information about the Digitalmars-d mailing list