halide/Halide — pull request #487 by dsharletg (2014-10-02 16:16:34+00:00)
Title: Typed Funcs

This PR adds a template version of Func, FuncT. This allows the user to define a Func that returns FuncRefExpr/FuncVarExpr that implicitly convert to T instead of Expr. This way, users can define operator overloads and other useful functions for their type. To test/demonstrate the feature, I updated the FFT test to use a complex number type with the appropriate operator overloads.

I expect this change to be controversial and I'm not completely sure we should merge it (at least I expect we might want to make some big changes). Any thoughts/improvements very welcome! In particular, if you find a way to make operator overloading work without the forwarding monstrosity in Func.h, I'd love to see it.