This works:

    extern(C) alias F = void function();
              alias G = void function();

    void foo(F f) {}
    void foo(G g) {}

Indeed, the correct foo is called, depending on whether the passed function is extern(C) or not (although I must say that the syntax for declaring the alias F is not good, IMO; the extern(C) should come after the equal sign).

Yet, the following does not work:

    void foo(T)(F f) {}
    void foo(G g) {}

    Error: function foo conflicts with template foo(T)(F f).

or

    void foo(F f) {}
    void foo(T)(G g) {}

    Error: template foo(T)(E e) conflicts with function foo.

It this not incoherent? If non-templated functions can overload on extern(C)/non-extern(C) function parameter, why can't templated functions?

Reply via email to