microsoft / hlsl-specs

HLSL Specifications
MIT License
116 stars 29 forks source link

Templated operators #251

Open Fletterio opened 2 months ago

Fletterio commented 2 months ago

With HLSL2021, we got both templated functions and templated struct methods. However, I am unable to template operator overloads, which is something I expected I would be able to do.

I would like to be able to do stuff like showcased in the Godbolt above.

llvm-beanz commented 3 weeks ago

I think this will somewhat work out of the box in Clang's HLSL implementation (see: https://godbolt.org/z/5df61eabK), but it will be really gnarly to fix in DXC because of DXC's custom overload resolution not handling C++ operators and templates correctly.

I'm marking this as a HLSL 202y feature because it is likely something we'll intentionally support in Clang but not in DXC and DXC will not support HLSL 202y.