Need trait of isPod.

Paolo Invernizzi arathorn at NO_SPAMfastwebnet.it
Mon Oct 8 23:11:10 PDT 2007


Not related... but what's the expression for testing an associative 
array? DMD 1.0 please...

Paolo

Aarti_pl wrote:
> Matti Niemenmaa pisze:
>> Aarti_pl wrote:
>>> Yang Bo pisze:
>>>> Because I really want to know whether a type is pod.
>>> Simple template should be just enough.
>>>
>>> See: 
>>> http://dsource.org/projects/tango/browser/trunk/tango/core/Variant.d
>>>
>>>
>>> template isAtomicType( T ) {
>>>     static if( is( T == bool )
>>>          || is( T == char )
>>>              || is( T == wchar )
>>>              || is( T == dchar )
>>>              || is( T == byte )
>>>              || is( T == short )
>>>              || is( T == int )
>>>              || is( T == long )
>>>              || is( T == ubyte )
>>>              || is( T == ushort )
>>>              || is( T == uint )
>>>              || is( T == ulong )
>>>              || is( T == float )
>>>              || is( T == double )
>>>              || is( T == real )
>>>              || is( T == ifloat )
>>>              || is( T == idouble )
>>>              || is( T == ireal ) )
>>>          const isAtomicType = true;
>>>     else
>>>              const isAtomicType = false;
>>> }
>>
>> That misses structs, which are also POD.
>>
> 
> It should be just enough to add additional condition:
> 
>     (...)
>     || is( T == struct )
>     (...)
> 
> and also probably union and enum.
> 
> More:
> http://digitalmars.com/d/expression.html  (section: is expression)
> 
> 
> BR
> Marcin Kuszczak
> (aarti_pl)



More information about the Digitalmars-d mailing list