[Issue 9065] Please consider adding these std.traits
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Sep 18 08:34:13 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=9065
Rory <rjmcguire at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rjmcguire at gmail.com
--- Comment #52 from Rory <rjmcguire at gmail.com> ---
(In reply to Manu from comment #11)
> template isEnum( T )
> {
> enum isEnum = is( T == enum );
> }
>
> // test if something is a variable; has a value, has an address
> template isVariable( alias T )
> {
> enum isVariable = !is( T ) && is( typeof( T ) ) // if it is not a type, and
> does have a type, it starts to look like a variable
> && !isFunction!T // reject function definitions, they can't be
> assigned to
> && !isEnum!T // reject enum's
> && !is( typeof( T ) == void ); // reject modules, which appear as a
> variable of type 'void'
> }
Thanks for this, I used this in Adam's jsvar to get a more meaningful
conversion from enum to bool which was initially causing the module to not be
valid because isIntegral!(some enum) == true.
--
More information about the Digitalmars-d-bugs
mailing list