OBSOLETE IN D2
Inserts a compile-time check that ensures a given type is a character type. (ie, char, wchar, or dchar)
Usage:
void funcForStringsOnly(T)(T[] str) { //Note, the second param is optional mixin(ensureCharType!("T", "funcForStringsOnly")); //Do stuff return str; } funcForStringsOnly("hello"); // Ok funcForStringsOnly([cast(int)1,2,3]); // Compile error
Turns Into:
{ static assert( is(T==char) || is(T==wchar) || is(T==dchar), "From 'funcForStringsOnly': 'T' must be char, wchar or dchar, not '"~T.stringof~"'" );`; //Do stuff return str; } funcForStringsOnly("hello"); // Ok funcForStringsOnly([cast(int)1,2,3]); // Compile error
Compiler Output:
Error: static assert "From 'funcForStringsOnly': 'T' must be char, wchar or dchar, not 'int'"
See Implementation
OBSOLETE IN D2
Inserts a compile-time check that ensures a given type is a character type. (ie, char, wchar, or dchar)
Usage:
Turns Into:
{ static assert( is(T==char) || is(T==wchar) || is(T==dchar), "From 'funcForStringsOnly': 'T' must be char, wchar or dchar, not '"~T.stringof~"'" );`; //Do stuff return str; } funcForStringsOnly("hello"); // Ok funcForStringsOnly([cast(int)1,2,3]); // Compile error
Error: static assert "From 'funcForStringsOnly': 'T' must be char, wchar or dchar, not 'int'"