2013/5/28 Manu <turkey...@gmail.com>

> So I've run into an expression I need to be able to implement std.simd
> properly for GDC/LDC.
>
> Doesn't work:
>   @attribute("target", T) void func(string T)(...);
>
> In this case, currently, the UDA can't receive the template arg that was
> given to the function.
>
> I require that attributes on templates be able to make use of the template
> args, since the template arg given may affect the attribute in some
> circumstances.
>

This code works.

string attribute(string, string s) { return s; }

//@attribute("target", T) void func(string T)() {}
template func(string T)
{
    @attribute("target", T) void func() {}
}

void main()
{
    alias f1 = func!"a";
    alias f2 = func!"b";
    pragma(msg, __traits(getAttributes, f1));   // "a"
    pragma(msg, __traits(getAttributes, f2));   // "b"
    f1();
    f2();
}

Kenji Hara

Reply via email to