<div dir="ltr">So we talked about this at DConf.<div><br></div><div style>Working on std.simd, I need to be able to change the target parameter on a per-function basis.</div><div style>GCC supports this via: __attribute__((target("sse2"))) for instance.</div>
<div style><br></div><div style>I need the ability to set this from D, but the trick is, I need to be able to set the target string according to a template arg.</div><div style><br></div><div style>Eg:</div><div style>  enum Targets { SSE2, SSE3 };</div>
<div style>  enum targets[] = [ "sse2", "sse3" ];<br></div><div style><br></div><div style>  @attribute("target", targets[T]) // <- attribute needs to refer to the template arg T</div><div style>
  void func(Targets T)();</div><div style><br></div><div style><br></div><div style>  {</div><div style>    // this way, it is possibly to produce dynamic selection of code paths optimised for different CPU features (a task which is usually very tedious in C/C++)</div>
<div style>    func!(Targets.SSE2)();</div><div style>  }</div><div style><br></div></div>