www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Check if template param is null

reply Andrea Fontana <nospam example.com> writes:
Is there a (compile time) way to check if a template param is null?

static if ( is (T:int) ) ....
else static if ( is(T:long) ) ....
// how to check if T =3D=3D null ?
Jul 11 2012
parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Wednesday, July 11, 2012 09:59:44 Andrea Fontana wrote:
 Is there a (compile time) way to check if a template param is null?
 
 static if ( is (T:int) ) ....
 else static if ( is(T:long) ) ....
 // how to check if T == null ?
Check if its type is typeof(null): is(T == typeof(null)) - Jonathan M Davis
Jul 11 2012
parent Andrea Fontana <nospam example.com> writes:
Whoops I tried typeof(T) =3D=3D null :)



Il giorno mer, 11/07/2012 alle 01.02 -0700, Jonathan M Davis ha scritto:

 On Wednesday, July 11, 2012 09:59:44 Andrea Fontana wrote:
 Is there a (compile time) way to check if a template param is null?
=20
 static if ( is (T:int) ) ....
 else static if ( is(T:long) ) ....
 // how to check if T =3D=3D null ?
=20 Check if its type is typeof(null): =20 is(T =3D=3D typeof(null)) =20 - Jonathan M Davis
Jul 11 2012