On Friday, 7 October 2016 at 02:13:21 UTC, Manu wrote:
Perhaps you'd like to give it a go ;)

Something like:

template delegateTypeForInoutMethod(T, string method)
{
  alias delegateTypeForInoutMethod = [write lots of stuff here];
}

struct S
{
inout(int)[] f(ref const(int) arg) inout pure nothrow { return [ arg ]; }
}

static assert(delegateTypeForInoutMethod!(const(S), "f") ==
const(int)[] delegate(ref const(int)) pure nothrow, "You failed!");

https://gist.github.com/thewilsonator/06fe58b06eb7b2d97a675f95bb4d3fac

passes the static assert. Sorry for the ugly mess, I don't have much time to clean it up today.

Lesson: never be afraid to resort to mixins.

Reply via email to