here's dustmited source:

template unaryFun(alias fun, string parmName="a") {
  static if (is(typeof(fun)))
    auto unaryFun(ElementType) (auto ElementType __a) {
      mixin("alias " ~ parmName ~ " = __a ;");
      return mixin(fun);
    } else static if (needOpCallAlias) {
      unaryFun fun;
    }
}


unittest {
  cast(void)unaryFun!"a+1"(41); // silence warning
}


unittest {
  struct Foo2 {
    int fun (int n) pure nothrow @safe @nogc { return n; }
  }

  import std.traits;
  pragma(msg, ParameterTypeTuple!(typeof(Foo2.fun)));
}


# dmd -c -o- -unittest test.d to see `(auto int)`

note that after removing any attribute from `Foo2.foo` will emit correct `(int)`.

Reply via email to