On Tuesday, 28 April 2015 at 02:36:38 UTC, Vladimir Panteleev wrote:
http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/

A truly polymorphic identity function in D would be more involved:

template id(a...) if (a.length == 1)
{
    static if (__traits(compiles, { alias id = a[0]; } ))
        alias id = a[0];
    else
        enum id = a[0];
}

static assert(is(id!int == int));
static assert(id!1 == 1);

Also, an 'isEqual' template would be needed to unify 'isSame', 'is' and '=='.

Reply via email to