Need trait of isPod.
Aarti_pl
aarti at interia.pl
Tue Oct 9 06:14:15 PDT 2007
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