Problem with templates

Sean Reque seanthenewt at yahoo.com
Mon Jul 7 10:08:10 PDT 2008


I just tried a D2 version of the curry function and it actually didn't work. I swore I wrote one before that worked. Maybe I should try it with an older D compiler. I wrote this code: 

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(U args) { return dg(A, 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
}


The compiler returns this error:

dmd2: glue.c:847: virtual unsigned int Type::totym(): Assertion `0' failed.




More information about the Digitalmars-d-learn mailing list