templates and scoping

BCS none at anon.com
Thu Apr 1 10:38:37 PDT 2010


Hello Ellery,

> this is going to be a bit of a nebulous question, but
> 
> if I define a template
> 
> template T(string s){
> }
> where s is an identifier, then is there a good way to branch T's
> behavior based on whether s is declared in the scope in which T gets
> instantiated?
> 

some combination of "is()" "typeof" and "mixin()" should do it.

//untested

static if( mixin("is("~s~")") ) { ... }

-- 
... <IXOYE><





More information about the Digitalmars-d-learn mailing list