template instance cannot use local 'f' as parameter to non-global template

Trass3r un at known.com
Wed Jul 13 08:24:50 PDT 2011


Am 13.07.2011, 16:58 Uhr, schrieb Tyro[a.c.edwards] <nospam at home.com>:
> Don't know it this is the right answer or a possible bug but it does the  
> trick:
>
> void h() { import std.stdio; write("h()"); }
>
> class Bla
> {
>      mixin wrap!h;
> }
>
> mixin template wrap(alias f)
> {
>      void blub(typeof(&f) g = &f)
>      {
>      	g();
>      }
> }
>
> void main()
> {
>      Bla b = new Bla();
>      b.blub();
> }

Thanks!
Unfortunately it doesn't work with more complex functions:

Error: arithmetic/string type expected for value-parameter, not cl_errcode  
C function(cl_program program, uint param_name, ulong param_value_size,  
void* param_value, ulong* param_value_size_ret)


More information about the Digitalmars-d-learn mailing list