Type trait alias parameters being either a string or a type

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 15 01:42:29 PDT 2015


As a follow up to

http://forum.dlang.org/thread/waxtzdemkuzvqdwilulj@forum.dlang.org#post-waxtzdemkuzvqdwilulj:40forum.dlang.org

I'm trying to create a type trait isIndexableBy at

https://github.com/nordlow/justd/blob/isIndexableBy-problem/typecons_ex.d

DMD complains

typecons_ex.d(78,30): Error: template instance isUnsigned!("I") 
does not match template declaration isUnsigned(T)
typecons_ex.d(79,30): Error: template instance isIndex_!("I") 
does not match template declaration isIndex_(I)
typecons_ex.d(91,35): Error: template instance 
typecons_ex.isIndexType!("I") error instantiating
typecons_ex.d(95,19):        instantiated from here: 
isIndexableBy!(int[], "I")
typecons_ex.d(96,19): Error: template instance 
isIndexableBy!(int[3], ubyte) does not match template declaration 
isIndexableBy(R, alias I)
typecons_ex.d(183,20): Error: template typecons_ex.indexedBy 
cannot deduce function from argument types !(ubyte)(int[3]), 
candidates are:
typecons_ex.d(156,6):        typecons_ex.indexedBy(alias I, R)(R 
range) if (isIndexableBy!(R, I))

How do I make the call isUnsigned!I return false instead of error 
when I is a CT string literal?

Is my design sane ("D-ish")?


More information about the Digitalmars-d-learn mailing list