Problem with templates
    Jarrett Billingsley 
    kb3ctd2 at yahoo.com
       
    Mon Jul  7 10:25:07 PDT 2008
    
    
  
"Sean Reque" <seanthenewt at yahoo.com> wrote in message 
news:g4tjei$31ci$1 at digitalmars.com...
> Never mind, I wrote the function wrong. This actually works. Alpha 
> compilers have terrible error messages sometimes!
>
> import std.stdio;
>
> /* R is return type
> * A is first argument type
> * U is TypeTuple of rest of argument types
> */
> R delegate(U) Curry(R, A, U...)(R delegate(A, U) dg, A arg)
> {
>  return delegate R(U args) { return dg(arg, args); };
> }
>
> void main()
> {
>    int plus(int x, int y, int z)
>    {
> return x + y + z;
>    }
>
>    auto plus_two = Curry(&plus, 2);
>    writefln("%d", plus_two(6, 8)); // prints 16
> }
Of course it works, plus is a delegate :)
Now put "static" in front of the declaration of plus and watch it fail. 
    
    
More information about the Digitalmars-d-learn
mailing list