Thread overview | |||||
---|---|---|---|---|---|
|
July 11, 2012 Check if template param is null | ||||
---|---|---|---|---|
| ||||
Attachments:
| 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 ? |
July 11, 2012 Re: Check if template param is null | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrea Fontana | 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
|
July 11, 2012 Re: Check if template param is null | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis Attachments:
| Whoops I tried typeof(T) == 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?
> >
> > 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
|
Copyright © 1999-2021 by the D Language Foundation