[Issue 6614] std.traits should have an isFinal template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 27 13:00:02 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=6614



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-12-27 12:59:59 PST ---
So is the idea of the enhancement just to merge the two traits under a single
name via Phobos templates?

E.g. (using overloads):

import std.traits;

template isFinal(T) if (is(T == class))
{
    enum bool isFinal = __traits(isFinalClass, T);
}

template isFinal(alias T) if (isSomeFunction!T)
{
    enum bool isFinal = __traits(isFinalFunction, T);
}

class C
{
    void nf() { }
    static void sf() { }
    final void ff() { }
}

final class FC { }

static assert(!isFinal!(C.nf));
static assert(!isFinal!(C.sf));
static assert(isFinal!(C.ff));
static assert(!isFinal!(C));
static assert(isFinal!(FC));

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list