Thread overview
[Issue 10193] Template args to UDA's
May 22, 2014
Manu
Mar 21, 2021
Nicholas Wilson
Dec 17, 2022
Iain Buclaw
May 22, 2014
https://issues.dlang.org/show_bug.cgi?id=10193

--- Comment #5 from Manu <turkeyman@gmail.com> ---
Can we have some movement on this?
std.simd is blocked on this issue.

Here's the thing:

enum targets[] = [ "hello", "world" ];

@attribute("target", targets[Target])
T func(int Target, T)(T arg)
{
  return arg;
}


The UDA is based on a template arg, and this doesn't work. I try and expand it manually:

template func(int Target, T)
{
  @attribute("target", targets[Target])
  T func(T arg)
  {
    return arg;
  }
}

But this doesn't work either, it complains:
  Error: template func cannot deduce function from argument types
!()(__vector(int[4])), candidates are: ...


Is there a workaround solution available?
It'd be nice to support this directly as in the OP.

--
December 16, 2015
https://issues.dlang.org/show_bug.cgi?id=10193

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com

--- Comment #6 from Andrei Alexandrescu <andrei@erdani.com> ---
More discussion with an application: http://forum.dlang.org/thread/n4s66a$i9u$1@digitalmars.com

--
March 21, 2021
https://issues.dlang.org/show_bug.cgi?id=10193

Nicholas Wilson <iamthewilsonator@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |iamthewilsonator@hotmail.co
                   |                            |m

--- Comment #7 from Nicholas Wilson <iamthewilsonator@hotmail.com> ---
Does https://github.com/dlang/dmd/pull/5314 fix this well enough?

It enables void func(string T)() @attribute("target", T) {};

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=10193

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4

--