std.pattern..mixin temptes..std.concurrency

Simen kjaeraas simen.kjaras at gmail.com
Fri Jul 9 05:38:20 PDT 2010


Steven Schveighoffer <schveiguy at yahoo.com> wrote:
> I wish there was a way to optionally make the class final (i.e. make it  
> a parameter).

I first thought this to work:

template bar( bool b ) {
     mixin( b ? "final:" : "" );
     class bar {
     }
}

static assert( msg, __traits( isFinalClass, bar!true ) );
static assert( msg, !__traits( isFinalClass, bar!false ) );

But I guess mixin creates a new scope, rendering it useless.

-- 
Simen


More information about the Digitalmars-d mailing list