www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - template alias

reply "Luke J. West" <luke west.me.uk> writes:
Hi,

I don't want to keep typing isNumeric!T | isSomeChar!T. I want to type
isBuiltIn!T instead, but am trying to work out how to implement it.
Something like


template isBuiltInT(T) {const bool t=isNumeric!T | isSomeChar!T};}

alias isBuiltInT.t isBuiltIn;


But that doesn't compile. How should I be doing it?
(Of course I'm assuming that isNumeric!T | isSomeChar!T captures all
primitives.)

Thanks,

Luke
Jan 23 2011
parent "Simen kjaeraas" <simen.kjaras gmail.com> writes:
Luke J. West <luke west.me.uk> wrote:

 Hi,

 I don't want to keep typing isNumeric!T | isSomeChar!T. I want to type
 isBuiltIn!T instead, but am trying to work out how to implement it.
 Something like


 template isBuiltInT(T) {const bool t=isNumeric!T | isSomeChar!T};}

 alias isBuiltInT.t isBuiltIn;


 But that doesn't compile. How should I be doing it?
 (Of course I'm assuming that isNumeric!T | isSomeChar!T captures all
 primitives.)
Andrei already answered the main point here, but you are aware | means bitwise OR, right? It might work, but you should use ||. -- Simen
Jan 23 2011