Skip to content

Impossible to add template on operator() overload #5194

Open

Description

@kpentaris

I'm looking to add a template on an operator() overload, something like this:

struct Test {
    template<typename T>
    T operator()(const T x) {
        return x;
    }
    
};

[numthreads(32,1,1)]
void main() {
    Test t;
    t(5); // error
    t<uint>(5); // error
    t.operator()<uint>(5); // error
}

All syntax tests fail. Here is a link for testing: Link
Note that in C++ test(5) passes (the compiler infers the type) and t.operator()<uint>(5) passes as well.

Thank you in advance

Activity

  1. changed the title [-]Impossible to add template in operator() overload[/-] [+]Impossible to add template on operator() overload[/+] on May 9, 2023
  2. added
    bug
    hlsl2021
    hlsl-next
    and removed
    needs-triage
    on Jun 30, 2023
  3. llvm-beanz commented on Jun 30, 2023

    @llvm-beanz
    Collaborator

    This is caused by broken behavior in DXC's overload resolution. We have a bunch of related issues that will need to be addressed in order to support this planned fix for HLSL 202x.

    That feature is effectively going to result in us adopting C++ overload rules completely for HLSL, which should solve this and related issues.

  4. removed
    hlsl2021
    on Jul 31, 2023
  5. devshgraphicsprogramming commented on Aug 31, 2023

    @devshgraphicsprogramming

    Chris B (@llvm-beanz) did you disable operator= overloading too? its still in an example in the wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughlsl-next

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions