On Thursday, 19 April 2018 at 13:57:04 UTC, Simen Kjærås wrote:
Currently, there is no way (that I've found, at least) to do this. If you have a workaround, that's great, but there really should be a way - probably __traits(getOverloads). Having __traits(getOverloads) return templates as well should fix some of the issues __traits(getOverloads) has, as a bonus.


Would it be possible at all? I mean, if the two following codes are equivalent
´´´
    @S("Has foo_A") template foo(string s) if (s == "a") {
        enum foo = "foo_A";
    }
    @S("Has foo_B") template foo(string s) if (s == "b") {
        enum foo = "foo_B";
    }
´´´


´´´
    template foo(string s)
    {
        static if (s == "a")
        {
               @S("Has foo_A") enum foo = "foo_A";
        }
        else static if (s == "b")
        {
              @S("Has foo_B") enum foo = "foo_B";
        }
    }
´´´

How would you define a "template overload"?
And which "overloads" would you like to get if constraints are more general? And last but not least, the getOverloads is defined on functions, which are callable, whereas templates are not, in general...

Reply via email to